From ec113ac4e070fc2d8e0dcf0f6fcc97792a574b77 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 4ccf5c4a5..a9378a731 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -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 { -- 2.47.2