From 1ec3777cb89a2c19e45154ab84ea3a24f47c086d Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 17 Jun 2017 23:46:50 +0200 Subject: image: Call image_free() when image_append() is failing --- src/image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/image.c b/src/image.c index 9cb3e41..43478f6 100644 --- a/src/image.c +++ b/src/image.c @@ -162,8 +162,10 @@ static int image_append(struct image * image, const char * type, const char * de image->hash = image_hash_from_data(image); image->devices = calloc(1, sizeof(struct device_list)); - if ( ! image->devices ) - return -1; + if ( ! image->devices ) { + image_free(image); + ALLOC_ERROR_RETURN(-1); + } image->devices->device = DEVICE_ANY; -- cgit v1.2.3