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 b567b2950cd27a51c4b9c3902ccc06e61b0ad509..92d44856e5bec648c7a364d8505b90477eb90e2a 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;