[PATCH 2/4] scripts: common: fix buffer freeing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We pass the wrong address to free in case of an error occured in
preceding while-read loop if the loop is executed more than once. Fix
this by use the outbuf which stores the original malloc'ed address.

Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>
---
 scripts/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/common.c b/scripts/common.c
index 0599cd41ff..49c468a1ea 100644
--- a/scripts/common.c
+++ b/scripts/common.c
@@ -76,8 +76,8 @@ int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_si
 	ret = 0;
 	goto close;
 free:
+	free(*outbuf);
 	*outbuf = NULL;
-	free(buf);
 close:
 	close(fd);
 	return ret;
-- 
2.41.0





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux