[libvirt] [PATCH] tests: Fix leak in securityselinuxtest

John Ferlan jferlan at redhat.com
Wed Aug 23 16:35:54 UTC 2017


If we jump to the error: label and @secbuf is allocated, then it's not
free'd at all.

Found by Coverity

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 tests/securityselinuxtest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index f6bc07a..0ac2828 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -68,7 +68,7 @@ testBuildDomainDef(bool dynamic,
                    const char *baselabel)
 {
     virDomainDefPtr def;
-    virSecurityLabelDefPtr secdef;
+    virSecurityLabelDefPtr secdef = NULL;
 
     if (!(def = virDomainDefNew()))
         goto error;
@@ -98,6 +98,7 @@ testBuildDomainDef(bool dynamic,
 
  error:
     virDomainDefFree(def);
+    virSecurityLabelDefFree(secdef);
     return NULL;
 }
 
-- 
2.9.5




More information about the libvir-list mailing list