[lxc-devel] [lxc/master] coverity: #1436916

2xsec on Github lxc-bot at linuxcontainers.org
Thu Jun 14 01:38:21 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 371 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180614/f7407907/attachment.bin>
-------------- next part --------------
From db8b325a3cacc5e213d37deda72c49460e9ca8a2 Mon Sep 17 00:00:00 2001
From: Donghwa Jeong <dh48.jeong at samsung.com>
Date: Thu, 14 Jun 2018 10:36:46 +0900
Subject: [PATCH] coverity: #1436916

Resource leak

Signed-off-by: Donghwa Jeong <dh48.jeong at samsung.com>
---
 src/lxc/tools/lxc_unshare.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/lxc/tools/lxc_unshare.c b/src/lxc/tools/lxc_unshare.c
index eb69068af..699823bff 100644
--- a/src/lxc/tools/lxc_unshare.c
+++ b/src/lxc/tools/lxc_unshare.c
@@ -101,8 +101,10 @@ static bool lookup_user(const char *optarg, uid_t *uid)
 
 	if (sscanf(optarg, "%u", uid) < 1) {
 		/* not a uid -- perhaps a username */
-		if (sscanf(optarg, "%s", name) < 1)
+		if (sscanf(optarg, "%s", name) < 1) {
+			free(buf);
 			return false;
+		}
 
 		ret = getpwnam_r(name, &pwent, buf, bufsize, &pwentp);
 		if (!pwentp) {


More information about the lxc-devel mailing list