[PATCH 1/4] vshtabletest: Fix potential memleak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/vshtabletest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
index 41ceec0a51..2b997753ff 100644
--- a/tests/vshtabletest.c
+++ b/tests/vshtabletest.c
@@ -33,7 +33,9 @@
 static int
 testVshTableNew(const void *opaque G_GNUC_UNUSED)
 {
-    if (vshTableNew(NULL)) {
+    g_autoptr(vshTable) table = vshTableNew(NULL);
+
+    if (table) {
         fprintf(stderr, "expected failure when passing null to vshTableNew\n");
         return -1;
     }
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux