]> git.proxmox.com Git - mirror_lxc.git/commitdiff
coverity: #1425921
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 7 Dec 2017 14:14:37 +0000 (15:14 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 7 Dec 2017 14:14:37 +0000 (15:14 +0100)
free allocated memory

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

index afe9ab8afb6f2bd8f961df1ebf0c4edd493d1f0f..fa6c3cf295784811c6ec166b95bd3293c994ee43 100644 (file)
@@ -599,6 +599,7 @@ static char *lxc_attach_getpwshell(uid_t uid)
                if (waitpid(pid, &status, 0) < 0) {
                        if (errno == EINTR)
                                goto again;
+                       free(result);
                        return NULL;
                }
 
@@ -607,14 +608,20 @@ static char *lxc_attach_getpwshell(uid_t uid)
                 * don't.
                 */
 
-               if (!WIFEXITED(status))
+               if (!WIFEXITED(status)) {
+                       free(result);
                        return NULL;
+               }
 
-               if (WEXITSTATUS(status) != 0)
+               if (WEXITSTATUS(status) != 0) {
+                       free(result);
                        return NULL;
+               }
 
-               if (!found)
+               if (!found) {
+                       free(result);
                        return NULL;
+               }
 
                return result;
        } else {