[CRIU] [PATCH] config: fix valgrind leak

Adrian Reber adrian at lisas.de
Tue Jul 24 19:18:29 MSK 2018


From: Adrian Reber <areber at redhat.com>

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 at redhat.com>
---
 criu/config.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/criu/config.c b/criu/config.c
index f3bf35b5f..a39696dc3 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -121,9 +121,11 @@ static char ** parse_config(char *filepath)
 			}
 			i++;
 		}
+		free(line);
 		line = NULL;
 	}
 
+	free(line);
 	fclose(configfile);
 	return configuration;
 }
-- 
2.17.1



More information about the CRIU mailing list