firmware-utils: tplink-safeloader: add calloc error handling
authorHyeonsik Song <blogcin@naver.com>
Mon, 25 Jun 2018 02:02:43 +0000 (11:02 +0900)
committerMathias Kresin <dev@kresin.me>
Tue, 3 Jul 2018 23:20:01 +0000 (01:20 +0200)
Signed-off-by: Hyeonsik Song <blogcin@naver.com>
tools/firmware-utils/src/tplink-safeloader.c

index b567b29..92d4485 100644 (file)
@@ -1638,6 +1638,10 @@ static int add_flash_partition(
        }
 
        part_list->name = calloc(1, strlen(name) + 1);
+       if (!part_list->name) {
+               error(1, 0, "Unable to allocate memory");
+       }
+
        memcpy((char *)part_list->name, name, strlen(name));
        part_list->base = base;
        part_list->size = size;