image: Call image_free() when image_append() is failing

This commit is contained in:
Pali Rohár committed 2017-06-17 23:46:50 +02:00
1 parent 897919a70f
commit 1ec3777cb8
1 file changed
+4 -2
+4 -2
View File
@@ -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->hash = image_hash_from_data(image);
image->devices = calloc(1, sizeof(struct device_list)); image->devices = calloc(1, sizeof(struct device_list));
if ( ! image->devices ) if ( ! image->devices ) {
return -1; image_free(image);
ALLOC_ERROR_RETURN(-1);
}
image->devices->device = DEVICE_ANY; image->devices->device = DEVICE_ANY;