[lxc-devel] [lxc/master] tests: containertests: fix dereference pointer c

2xsec on Github lxc-bot at linuxcontainers.org
Thu Aug 9 04:40:13 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 403 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180809/ba19e029/attachment.bin>
-------------- next part --------------
From ed819a4dbcf85ea4d6b1288553024032bd929367 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Thu, 9 Aug 2018 13:37:22 +0900
Subject: [PATCH] tests: containertests: fix dereference pointer c

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/tests/containertests.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/tests/containertests.c b/src/tests/containertests.c
index 1412b0b84..b28bcd56d 100644
--- a/src/tests/containertests.c
+++ b/src/tests/containertests.c
@@ -149,8 +149,15 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	if (lxc_container_put(c) != 0) {
+	ret = lxc_container_put(c);
+	if (ret < 0) {
+		fprintf(stderr, "%d: c is invalid pointer\n", __LINE__);
+		ret = 1;
+		goto out;
+	}
+	else if (ret == 1) {
 		fprintf(stderr, "%d: c was freed on non-final put\n", __LINE__);
+		c = NULL;
 		goto out;
 	}
 
@@ -257,8 +264,8 @@ int main(int argc, char *argv[])
 	if (c) {
 		c->stop(c);
 		destroy_busybox();
+		lxc_container_put(c);
 	}
 
-	lxc_container_put(c);
 	exit(ret);
 }


More information about the lxc-devel mailing list