]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix error reporting when parsing CPU XML strings
authorJiri Denemark <jdenemar@redhat.com>
Wed, 24 Feb 2010 20:50:54 +0000 (21:50 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 23 Mar 2010 14:40:10 +0000 (15:40 +0100)
src/cpu/cpu.c

index 501a00ca8cc1dfd098d8df7d30af56176438b0d7..be0f15e6c7df750940b215809d3933b8002c1276 100644 (file)
@@ -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);