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

John Ferlan posted 1 patch 6 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170823163554.12014-1-jferlan@redhat.com
tests/securityselinuxtest.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] tests: Fix leak in securityselinuxtest
Posted by John Ferlan 6 years, 8 months ago
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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: Fix leak in securityselinuxtest
Posted by Ján Tomko 6 years, 8 months ago
On Wed, Aug 23, 2017 at 12:35:54PM -0400, John Ferlan wrote:
>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@redhat.com>
>---
> tests/securityselinuxtest.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>

ACK

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list