util/cbfstool: Make cbfs_image_delete() NULL-tolerant.
This fixes a double free crash that occurs when a call to cbfs_image_from_file() fails in cbfs_extract() and falls though to cbfs_image_delete() with a NULL-pointer. To reproduce the crash pass the following arguments where the files passed, in fact, do not exist. As follows: ./cbfstool build/coreboot.rom extract -n config -f /tmp/config.txt Change-Id: I2213ff175d0703705a0ec10271b30bb26b6f8d0a Signed-off-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-on: http://review.coreboot.org/5353 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
parent
7c1a49bcc0
commit
a0f9ece19c
|
@ -300,6 +300,9 @@ int cbfs_image_write_file(struct cbfs_image *image, const char *filename)
|
||||||
|
|
||||||
int cbfs_image_delete(struct cbfs_image *image)
|
int cbfs_image_delete(struct cbfs_image *image)
|
||||||
{
|
{
|
||||||
|
if (image == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
buffer_delete(&image->buffer);
|
buffer_delete(&image->buffer);
|
||||||
image->header = NULL;
|
image->header = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue