]> 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>
Wed, 7 Feb 2018 11:18:24 +0000 (12:18 +0100)
free allocated memory

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

index f17a16f56b13a7f254c17c0aecd974de8960ea4d..4876d9ced1442bf73bb4c723184224c9b0a5f71d 100644 (file)
@@ -557,6 +557,7 @@ static char *lxc_attach_getpwshell(uid_t uid)
                if (waitpid(pid, &status, 0) < 0) {
                        if (errno == EINTR)
                                goto again;
+                       free(result);
                        return NULL;
                }
 
@@ -565,14 +566,20 @@ static char *lxc_attach_getpwshell(uid_t uid)
                 * we assume we 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 {