]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425886
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 9 Dec 2017 17:44:41 +0000 (18:44 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Dec 2017 12:25:44 +0000 (13:25 +0100)
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index fa6c3cf295784811c6ec166b95bd3293c994ee43..c83a4455ed6ae98aef2ba70cc267dab869587291 100644 (file)
@@ -1504,7 +1504,6 @@ int lxc_attach_run_shell(void* payload)
                user_shell = lxc_attach_getpwshell(uid);
        else
                user_shell = passwd->pw_shell;
-
        if (user_shell)
                execlp(user_shell, user_shell, (char *)NULL);
 
@@ -1512,6 +1511,8 @@ int lxc_attach_run_shell(void* payload)
         * on /bin/sh as a default shell.
         */
        execlp("/bin/sh", "/bin/sh", (char *)NULL);
-       SYSERROR("Failed to exec shell.");
+       SYSERROR("Failed to execute shell");
+       if (!passwd)
+               free(user_shell);
        return -1;
 }