[PATCH 2/4] scripts: common: fix buffer freeing
Marco Felsch
m.felsch at pengutronix.de
Tue Oct 17 14:36:06 PDT 2023
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 at pengutronix.de>
---
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
More information about the barebox
mailing list