From: Andrey Mazo Date: Mon, 23 Dec 2013 17:17:10 +0000 (+0400) Subject: Fix invalid free() in lxc_global_config_value(). X-Git-Tag: lxc-1.0.0.beta2~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ed46d9ea77c4dd57acb70bec1766edb1f2edbc1;p=thirdparty%2Flxc.git Fix invalid free() in lxc_global_config_value(). Commit 4878dac496543dae0a26f5c1156bbfda63c8ea62 introduced possible incorrect usage of free(). Also remove unneeded strdup(). Signed-off-by: Andrey Mazo Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/utils.c b/src/lxc/utils.c index b14657f56..dc30a778b 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -259,13 +259,10 @@ const char *lxc_global_config_value(const char *option_name) char *user_config_path = NULL; char *user_lxc_path = NULL; - char *user_home = NULL; if (geteuid() > 0) { - user_home = getenv("HOME"); - if (user_home) - user_home = strdup(user_home); - else + const char *user_home = getenv("HOME"); + if (!user_home) user_home = "/"; user_config_path = malloc(sizeof(char) * (22 + strlen(user_home))); @@ -273,8 +270,6 @@ const char *lxc_global_config_value(const char *option_name) sprintf(user_config_path, "%s/.config/lxc/lxc.conf", user_home); sprintf(user_lxc_path, "%s/.local/share/lxc/", user_home); - - free(user_home); } else { user_config_path = strdup(LXC_GLOBAL_CONF);