[CRIU] [PATCH 2/3] config: initialize the last element of a config argv as NULL
Andrei Vagin
avagin at virtuozzo.com
Wed May 9 09:28:28 MSK 2018
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 at virtuozzo.com>
---
criu/config.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/criu/config.c b/criu/config.c
index b1c0d58f5..75cc1f52f 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -98,8 +98,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) {
--
2.14.3
More information about the CRIU
mailing list