From b545bc96a9e1a875beb50d9202161864ca8164d8 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 2 Oct 2015 12:39:08 +0200 Subject: Fix a memory leak. g_get_current_dir() returns a heap-allocated string. --- src/core/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/core.c b/src/core/core.c index b9debbb5..879d346f 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -156,11 +156,17 @@ static void sig_init_finished(void) static char *fix_path(const char *str) { char *new_str = convert_home(str); + if (!g_path_is_absolute(new_str)) { char *tmp_str = new_str; - new_str = g_strdup_printf("%s/%s", g_get_current_dir(), tmp_str); + char *current_dir = g_get_current_dir(); + + new_str = g_build_path(G_DIR_SEPARATOR_S, current_dir, tmp_str); + + g_free(current_dir); g_free(tmp_str); } + return new_str; } -- cgit v1.2.3