[LEDE-DEV] [PATCH 4/4] otrx: fix memory leak in otrx_create_append_zeros

Rafał Miłecki zajec5 at gmail.com
Thu Nov 16 01:15:59 PST 2017


From: Rafał Miłecki <rafal at milecki.pl>

A "free" call was missing after allocating a buffer.

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 package/utils/otrx/src/otrx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/package/utils/otrx/src/otrx.c b/package/utils/otrx/src/otrx.c
index 1c3ffd915b..ac39fefc06 100644
--- a/package/utils/otrx/src/otrx.c
+++ b/package/utils/otrx/src/otrx.c
@@ -266,9 +266,12 @@ static ssize_t otrx_create_append_zeros(FILE *trx, size_t length) {
 
 	if (fwrite(buf, 1, length, trx) != length) {
 		fprintf(stderr, "Couldn't write %zu B to %s\n", length, trx_path);
+		free(buf);
 		return -EIO;
 	}
 
+	free(buf);
+
 	return length;
 }
 
-- 
2.11.0




More information about the Lede-dev mailing list