From 107aae01056f07bc540d04d26cc5db4ffb501f97 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Thu, 9 Aug 2012 16:00:20 +0200 Subject: [PATCH] env.c: free memory at exit. Make sure the memory for the 'base' string is always free'd when the program exits. --- env.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/env.c b/env.c index f5841d2..fd65a54 100644 --- a/env.c +++ b/env.c @@ -29,6 +29,12 @@ static char *base = NULL; +static void free_base() { + + if (base) + free(base); +} + static void get_base() { struct buffer buf = BUFFER_INIT; @@ -40,6 +46,7 @@ static void get_base() { buffer_append_str(&buf, "/.dlight"); base = buffer_cstr_release(&buf); + atexit(free_base); } const char* env_get_dir() {