2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

config: fix valgrind leak

Running 'criu dump -t <PID>' with a configuration file under valgrind
where <PID> does not exist, gives:

==14336== 600 bytes in 5 blocks are definitely lost in loss record 5 of 5
==14336==    at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==14336==    by 0x5D387A4: getdelim (in /usr/lib64/libc-2.17.so)
==14336==    by 0x439829: getline (stdio.h:117)
==14336==    by 0x439829: parse_config (config.c:69)
==14336==    by 0x439CB2: init_configuration.isra.1 (config.c:159)
==14336==    by 0x439F75: init_config (config.c:212)
==14336==    by 0x439F75: parse_options (config.c:487)
==14336==    by 0x42499F: main (crtools.c:140)

==14336== LEAK SUMMARY:
==14336==    definitely lost: 600 bytes in 5 blocks

With this patch:

==17892== LEAK SUMMARY:
==17892==    definitely lost: 0 bytes in 0 blocks

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Adrian Reber
2018-07-24 18:18:29 +02:00
committed by Andrei Vagin
parent 15b4d9205b
commit bab6c7b74b

View File

@@ -121,9 +121,11 @@ static char ** parse_config(char *filepath)
}
i++;
}
free(line);
line = NULL;
}
free(line);
fclose(configfile);
return configuration;
}