]> 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>
Sun, 17 Dec 2017 15:27:37 +0000 (16:27 +0100)
free allocated memory

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

index a9378a731245ec4aa0959aabc7cc553304444ec6..7da8a733654cd2d2f372eadeaa74e6ba2ebcebe6 100644 (file)
@@ -1443,7 +1443,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);
 
@@ -1451,6 +1450,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;
 }