In str_to_strv(), during interation the strings if allocation is failed
after second chance, the allocated origin value v is leaked.
And recent gcc is safe for null free. So destroy value without check.
Change-Id: I7fda4d76484201b2ccb66f5617ca75d0e4ecb1aa
Signed-off-by: WaLyong Cho <walyong.cho@samsung.com>
FOREACH_WORD_SEPARATOR(w, l, str, separator, state) {
p = strndup(w, l);
if (!p) {
- if (v)
- free(v);
+ free(v);
return -ENOMEM;
}
new = (char **)realloc(v, sizeof(char *) * (i + 2));
if (!new) {
free(p);
+ free(v);
p = NULL;
return -ENOMEM;
}