From 8b7482a5efc7ea3af1408eb63aadbf0d02daab4b Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 7 Dec 2017 15:14:37 +0100 Subject: [PATCH] coverity: #1425921 free allocated memory Signed-off-by: Christian Brauner --- src/lxc/attach.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index afe9ab8af..fa6c3cf29 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -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 { -- 2.47.3