The function lxc_string_split_quoted and lxc_string_split_and_trim use
realloc to reduce the memory. But the result may be NULL, the the
returned memory will be uninitialized
Signed-off-by: LiFeng <lifeng68@huawei.com>
if (state == 'a')
complete_word(&result, nextword, p, &result_capacity, &result_count);
+ if (result == NULL)
+ return calloc(1, sizeof(char *));
+
return realloc(result, (result_count + 1) * sizeof(char *));
}
result_count++;
}
+ if (result == NULL)
+ return calloc(1, sizeof(char *));
+
/* if we allocated too much, reduce it */
return realloc(result, (result_count + 1) * sizeof(char *));