瀏覽代碼

firmware-utils: tplink-safeloader: add calloc error handling

Signed-off-by: Hyeonsik Song <[email protected]>
Hyeonsik Song 7 年之前
父節點
當前提交
c2766270ef
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      tools/firmware-utils/src/tplink-safeloader.c

+ 4 - 0
tools/firmware-utils/src/tplink-safeloader.c

@@ -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;