[libvirt] [PATCH 15/19] storage_conf: Resolve Coverity RESOURCE_LEAK

John Ferlan jferlan at redhat.com
Wed Aug 27 20:54:46 UTC 2014


If there was a failure processing 'authdef' and the code went to cleanup
before the setting to source->auth, then it'd be leaked.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/storage_conf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 5a16767..e72a869 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -661,6 +661,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
         }
 
         source->auth = authdef;
+        authdef = NULL;
     }
 
     source->vendor = virXPathString("string(./vendor/@name)", ctxt);
@@ -673,6 +674,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
     VIR_FREE(port);
     VIR_FREE(nodeset);
     VIR_FREE(adapter_type);
+    virStorageAuthDefFree(authdef);
     return ret;
 }
 
-- 
1.9.3




More information about the libvir-list mailing list