[libvirt] [PATCH 1/2] conf: Don't leak 'primary' video property on error

Christophe Fergeau cfergeau at redhat.com
Thu Feb 21 15:49:16 UTC 2013


It's only freed on normal returns from virDomainVideoDefParseXML,
but not when erroring out.
---
 src/conf/domain_conf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 10f361c..258ee93 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7662,9 +7662,11 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
                 vram = virXMLPropString(cur, "vram");
                 heads = virXMLPropString(cur, "heads");
 
-                if ((primary = virXMLPropString(cur, "primary")) != NULL)
+                if ((primary = virXMLPropString(cur, "primary")) != NULL) {
                     if (STREQ(primary, "yes"))
                         def->primary = 1;
+                    VIR_FREE(primary);
+                }
 
                 def->accel = virDomainVideoAccelDefParseXML(cur);
             }
@@ -7728,7 +7730,6 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     VIR_FREE(ram);
     VIR_FREE(vram);
     VIR_FREE(heads);
-    VIR_FREE(primary);
 
     return def;
 
-- 
1.8.1.2




More information about the libvir-list mailing list