]> git.ipfire.org Git - thirdparty/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>
Sun, 17 Dec 2017 15:26:42 +0000 (16:26 +0100)
free allocated memory

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

index 4ccf5c4a5d9993f24c9e336c7c8c50412a8f8699..a9378a731245ec4aa0959aabc7cc553304444ec6 100644 (file)
@@ -591,6 +591,7 @@ static char *lxc_attach_getpwshell(uid_t uid)
                if (waitpid(pid, &status, 0) < 0) {
                        if (errno == EINTR)
                                goto again;
+                       free(result);
                        return NULL;
                }
 
@@ -599,14 +600,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 {