]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpuCompare: Fix crash on unexpected CPU XML
authorJiri Denemark <jdenemar@redhat.com>
Mon, 12 Jul 2010 15:30:23 +0000 (17:30 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 12 Jul 2010 17:45:22 +0000 (19:45 +0200)
When comparing a CPU without <model> element, such as

    <cpu>
        <topology sockets='1' cores='1' threads='1'/>
    </cpu>

libvirt would happily crash without warning.

src/cpu/cpu.c

index 279eee7d37f201d48a600aea5733d96454fd2795..def69749a4c37cd043124441196bf0ceb6dcc377 100644 (file)
@@ -90,6 +90,12 @@ cpuCompareXML(virCPUDefPtr host,
     if (cpu == NULL)
         goto cleanup;
 
+    if (!cpu->model) {
+        virCPUReportError(VIR_ERR_OPERATION_INVALID,
+                "%s", _("no CPU model specified"));
+        goto cleanup;
+    }
+
     ret = cpuCompare(host, cpu);
 
 cleanup: