Unverified Commit 51bbca90 by Christian Brauner Committed by GitHub

Merge pull request #3864 from lifeng68/master

string utils: Make sure don't return uninitialized memory.
parents a197d2fb 47f5be06
......@@ -404,6 +404,9 @@ char **lxc_string_split_quoted(char *string)
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 *));
}
......@@ -443,6 +446,9 @@ char **lxc_string_split_and_trim(const char *string, char _sep)
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 *));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment