]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fix invalid free() in lxc_global_config_value().
authorAndrey Mazo <mazo@telum.ru>
Mon, 23 Dec 2013 17:17:10 +0000 (21:17 +0400)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 23 Dec 2013 18:32:27 +0000 (12:32 -0600)
Commit 4878dac496543dae0a26f5c1156bbfda63c8ea62 introduced possible
incorrect usage of free().
Also remove unneeded strdup().

Signed-off-by: Andrey Mazo <mazo@telum.ru>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/utils.c

index b14657f56b3e0c79b411ad634244e79c256e97c5..dc30a778b364cf4b09f398bc531c90b20d3ea2f7 100644 (file)
@@ -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);