summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2017-06-17 23:46:50 +0200
committerPali Rohár <pali.rohar@gmail.com>2017-06-17 23:46:50 +0200
commit1ec3777cb89a2c19e45154ab84ea3a24f47c086d (patch)
tree6a887cb7d06d16f25f91d5250914f42b99f92a18
parent897919a70fa030399e52792fa602e53590744e04 (diff)
download0xFFFF-1ec3777cb89a2c19e45154ab84ea3a24f47c086d.tar.bz2
image: Call image_free() when image_append() is failing
-rw-r--r--src/image.c6
1 files 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;