mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-15 21:26:57 +00:00
Merge pull request #3864 from lifeng68/master
string utils: Make sure don't return uninitialized memory.
This commit is contained in:
commit
51bbca901b
@ -404,6 +404,9 @@ char **lxc_string_split_quoted(char *string)
|
|||||||
if (state == 'a')
|
if (state == 'a')
|
||||||
complete_word(&result, nextword, p, &result_capacity, &result_count);
|
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 *));
|
return realloc(result, (result_count + 1) * sizeof(char *));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +446,9 @@ char **lxc_string_split_and_trim(const char *string, char _sep)
|
|||||||
result_count++;
|
result_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result == NULL)
|
||||||
|
return calloc(1, sizeof(char *));
|
||||||
|
|
||||||
/* if we allocated too much, reduce it */
|
/* if we allocated too much, reduce it */
|
||||||
return realloc(result, (result_count + 1) * sizeof(char *));
|
return realloc(result, (result_count + 1) * sizeof(char *));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user