From 7bfcbe55e150792af3733e767885e93bd998cdc3 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Sun, 5 Apr 2015 06:39:06 +0000 Subject: [PATCH] #5920: Fix memory leak and access to freed memory in tr_getDefaultConfigDir (patch by jyelloz) --- libtransmission/platform.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libtransmission/platform.c b/libtransmission/platform.c index 96d0e4bf7..8b8c66194 100644 --- a/libtransmission/platform.c +++ b/libtransmission/platform.c @@ -330,10 +330,11 @@ tr_getDefaultConfigDir (const char * appname) find_directory (B_USER_SETTINGS_DIRECTORY, -1, true, buf, sizeof (buf)); s = tr_buildPath (buf, appname, NULL); #else - if ((s = tr_env_get_string ("XDG_CONFIG_HOME", NULL))) + char * const xdg_config_home = tr_env_get_string ("XDG_CONFIG_HOME", NULL); + if (xdg_config_home != NULL) { - s = tr_buildPath (s, appname, NULL); - tr_free (s); + s = tr_buildPath (xdg_config_home, appname, NULL); + tr_free (xdg_config_home); } else {