[cbootimage PATCH] Free image buffer on read error

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

 



Free the buffer after a read error to prevent a memory leak. This was
flagged by a Coverity scan of the coreboot project, which uses
cbootimage.

Signed-off-by: Jacob Garber <jgarber1@xxxxxxxxxxx>
---
 src/set.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/set.c b/src/set.c
index 934a58d..2013169 100644
--- a/src/set.c
+++ b/src/set.c
@@ -98,6 +98,7 @@ read_from_image(char	*filename,
 	if (fread(*image, 1, (size_t)(*actual_size), fp) !=
 		(size_t)(*actual_size)) {
 		result = 1;
+		free(*image);
 		goto cleanup;
 	}
 
-- 
2.22.0




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux