Free image buffer on read error

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>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
Jacob Garber 2019-07-17 17:07:48 -06:00 committed by Stephen Warren
parent 9de64c77f0
commit 65a6d94dd5
1 changed files with 1 additions and 0 deletions

View File

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