From d4cd9530184835039f18a90defbf027d2df06eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Sat, 15 Apr 2023 23:09:03 +0200 Subject: [PATCH] main: Terminate immediately after image_alloc failure --- src/main.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 3a53b7a..f7db8f9 100644 --- a/src/main.c +++ b/src/main.c @@ -314,6 +314,12 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) { image = image_alloc_from_files(files, count, type, device, hwrevs, version, layout, image_parts); free(files); + free(layout); + + if ( ! image ) { + ERROR("Cannot load image file %s", file); + exit(1); + } image_part = image_parts; image_fd = image->fds; @@ -326,14 +332,6 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) { image_fd = image_fd->next; } - if ( layout ) - free(layout); - - if ( ! image ) { - ERROR("Cannot load image file %s", file); - exit(1); - } - image_list_add(image_first, image); }