From: John Ferlan Date: Thu, 20 Sep 2018 21:34:36 +0000 (-0400) Subject: conf: Alter when ctxt->node is set X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f5c7d8890bd84d5fd47ad4dbfbd285a9ebca303c;p=libvirt.git conf: Alter when ctxt->node is set 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 Reviewed-by: Erik Skultety --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1ee43950ae..9911d56130 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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"));