[source] otrx: fix memory leak in otrx_create_append_zeros

LEDE Commits lede-commits at lists.infradead.org
Fri Nov 17 02:32:59 PST 2017


rmilecki pushed a commit to source.git, branch master:
https://git.lede-project.org/36a92274a80056d224288721fa7c71b5ad9680b5

commit 36a92274a80056d224288721fa7c71b5ad9680b5
Author: Rafał Miłecki <rafal at milecki.pl>
AuthorDate: Thu Nov 16 10:14:30 2017 +0100

    otrx: fix memory leak in otrx_create_append_zeros
    
    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 0d99cd3..223e032 100644
--- a/package/utils/otrx/src/otrx.c
+++ b/package/utils/otrx/src/otrx.c
@@ -264,9 +264,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;
 }
 



More information about the lede-commits mailing list