2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

config: initialize the last element of a config argv as NULL

Now we rely on scanf, that it will initializes a pointer to NULL, when
it fails to parse a string, but I can't find in a man page, that it has
to do this.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Andrei Vagin
2018-05-09 09:28:28 +03:00
parent 133ff575db
commit 849183591b

View File

@@ -60,8 +60,10 @@ static char ** parse_config(char *filepath)
while (1) {
while ((isspace(*(line + offset)) && (*(line + offset) != '\n'))) offset++;
if (sscanf(line + offset, "%m[^ \t\n]s", &configuration[i]) != 1)
if (sscanf(line + offset, "%m[^ \t\n]s", &configuration[i]) != 1) {
configuration[i] = NULL;
break;
}
if (configuration[i][0] == '#') {
if (sscanf(line, "%*[^\n]") != 0) {