[cbootimage] Free image buffer on read error
diff mbox series

Message ID 20190717230748.23204-1-jgarber1@ualberta.ca
State New
Headers show
Series
  • [cbootimage] Free image buffer on read error
Related show

Commit Message

Jacob Garber July 17, 2019, 11:07 p.m. UTC
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@ualberta.ca>
---
 src/set.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Stephen Warren July 17, 2019, 11:47 p.m. UTC | #1
On 7/17/19 5:07 PM, Jacob Garber wrote:
> 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.

Thanks. Applied.

Patch
diff mbox series

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;
 	}