firmware-utils: tplink-safeloader: add calloc error handling
authorHyeonsik Song <[email protected]>
Mon, 25 Jun 2018 02:02:43 +0000 (11:02 +0900)
committerJo-Philipp Wich <[email protected]>
Tue, 18 Dec 2018 16:32:19 +0000 (17:32 +0100)
Signed-off-by: Hyeonsik Song <[email protected]>
(backported from c2766270efcba795f1d14f9a51f07898eb8a62c1)

tools/firmware-utils/src/tplink-safeloader.c

index eda4ea53a5a798803d3cf4a07751d876f5b9284c..959b35195986b660e8e999a52a65220abd514b7f 100644 (file)
@@ -1607,6 +1607,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;