From 81e99f014ba4c033d6158118ac6b2fea32433f7d Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 24 Feb 2010 21:50:54 +0100 Subject: [PATCH] Fix error reporting when parsing CPU XML strings --- src/cpu/cpu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 501a00ca8c..be0f15e6c7 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -73,9 +73,10 @@ cpuCompareXML(virCPUDefPtr host, virCPUDefPtr cpu = NULL; 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(); goto cleanup; } @@ -268,8 +269,10 @@ cpuBaselineXML(const char **xmlCPUs, goto no_memory; for (i = 0; i < ncpus; i++) { - doc = xmlParseMemory(xmlCPUs[i], strlen(xmlCPUs[i])); - if (doc == NULL || (ctxt = xmlXPathNewContext(doc)) == NULL) + if (!(doc = virXMLParseString(xmlCPUs[i], "cpu.xml"))) + goto error; + + if ((ctxt = xmlXPathNewContext(doc)) == NULL) goto no_memory; ctxt->node = xmlDocGetRootElement(doc);