]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Alter when ctxt->node is set
authorJohn Ferlan <jferlan@redhat.com>
Thu, 20 Sep 2018 21:34:36 +0000 (17:34 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 24 Sep 2018 12:50:02 +0000 (08:50 -0400)
In virDomainMemoryDefParseXML and virDomainVideoDefParseXML if
the VIR_ALLOC fails and NULL is returned, then the alteration
to ctxt->node isn't reversed.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/conf/domain_conf.c

index 1ee43950ae2df0d6990faae75430ea298a1dea40..9911d56130a9ce219bbdd040d9b1c81ffb79a41d 100644 (file)
@@ -15089,11 +15089,11 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xmlopt,
     char *vgamem = NULL;
     char *primary = NULL;
 
-    ctxt->node = node;
-
     if (!(def = virDomainVideoDefNew()))
         return NULL;
 
+    ctxt->node = node;
+
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
@@ -15830,11 +15830,11 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xmlopt,
     virDomainMemoryDefPtr def;
     int val;
 
-    ctxt->node = memdevNode;
-
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
+    ctxt->node = memdevNode;
+
     if (!(tmp = virXMLPropString(memdevNode, "model"))) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("missing memory model"));