46 lines
1.4 KiB
Diff
46 lines
1.4 KiB
Diff
From e210025037fbd00c81e8faa0a5339dccdc0c75a1 Mon Sep 17 00:00:00 2001
|
|
From: wangmeiyang <wangmeiyang_yewu@cmss.chinamobile.com>
|
|
Date: Thu, 24 Nov 2022 09:10:25 +0800
|
|
Subject: [PATCH 12/23] vshtabletest: Fix potential memleak
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
In testVshTableNew() we test whether vshTableNew(NULL) allocates
|
|
a table. This is expected to fail (and return NULL), because
|
|
passing nothing but NULL to vshTableNew() is viewed as error.
|
|
Nevertheless, if vshTableNew() did not fail and returned an
|
|
allocated table it would be leaked.
|
|
|
|
cherry-pick from eb9bbde7721af765d88086dc3055cff092436c58
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Signed-off-by: Meiyang Wang <wangmeiyang_yewu@cmss.chinamobile.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
tests/vshtabletest.c | 5 +++--
|
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
|
|
index 15369d8eb2..348f525234 100644
|
|
--- a/tests/vshtabletest.c
|
|
+++ b/tests/vshtabletest.c
|
|
@@ -33,11 +33,12 @@
|
|
static int
|
|
testVshTableNew(const void *opaque G_GNUC_UNUSED)
|
|
{
|
|
- if (vshTableNew(NULL)) {
|
|
+ vshTablePtr table = vshTableNew(NULL);
|
|
+ if (table) {
|
|
fprintf(stderr, "expected failure when passing null to vshTableNew\n");
|
|
return -1;
|
|
}
|
|
-
|
|
+ vshTableFree(table);
|
|
return 0;
|
|
}
|
|
|
|
--
|
|
2.27.0
|
|
|