From 50632629ffc14c35b2698d80137df2fc936f0447 Mon Sep 17 00:00:00 2001 From: Tim Pepper Date: Thu, 6 Sep 2012 14:56:30 -0700 Subject: [PATCH] Correct memory management around os-release/version Valgrind reminded me I should correctly dup the substring and free the original full string. Signed-off-by: Tim Pepper --- src/coredump.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/coredump.c b/src/coredump.c index 2fee61f..ae9fd75 100644 --- a/src/coredump.c +++ b/src/coredump.c @@ -79,10 +79,13 @@ static char *get_release(void) char *c = NULL; c = strchr(line, '\n'); - if (c) *c = 0; - - fclose(file); - return &line[11]; + if (c) { + *c = 0; + c = strdup(&line[11]); + fclose(file); + free(line); + return c; + } } } -- 2.7.4