Fix error reporting when parsing CPU XML strings

This commit is contained in:
Jiri Denemark 2010-02-24 21:50:54 +01:00
parent 8d8815ea2a
commit 81e99f014b

View File

@ -73,9 +73,10 @@ cpuCompareXML(virCPUDefPtr host,
virCPUDefPtr cpu = NULL; virCPUDefPtr cpu = NULL;
virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR; virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
doc = xmlParseMemory(xml, strlen(xml)); if (!(doc = virXMLParseString(xml, "cpu.xml")))
goto cleanup;
if (doc == NULL || (ctxt = xmlXPathNewContext(doc)) == NULL) { if ((ctxt = xmlXPathNewContext(doc)) == NULL) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
} }
@ -268,8 +269,10 @@ cpuBaselineXML(const char **xmlCPUs,
goto no_memory; goto no_memory;
for (i = 0; i < ncpus; i++) { for (i = 0; i < ncpus; i++) {
doc = xmlParseMemory(xmlCPUs[i], strlen(xmlCPUs[i])); if (!(doc = virXMLParseString(xmlCPUs[i], "cpu.xml")))
if (doc == NULL || (ctxt = xmlXPathNewContext(doc)) == NULL) goto error;
if ((ctxt = xmlXPathNewContext(doc)) == NULL)
goto no_memory; goto no_memory;
ctxt->node = xmlDocGetRootElement(doc); ctxt->node = xmlDocGetRootElement(doc);