]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu: Set nfeatures_max correctly in x86Decode
authorJiri Denemark <jdenemar@redhat.com>
Thu, 4 Aug 2016 22:01:42 +0000 (00:01 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 22 Sep 2016 13:40:09 +0000 (15:40 +0200)
Keeping nfeatures_max set to 0 while nfeatures > 0 and some features are
already stored in features array is just asking for problems once we
want to add a new feature into the array.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/cpu/cpu_x86.c

index bd2670374ced8eaa46bec4a3b73fdd1ab4e19dfd..f424f7205f68e17730d9e6e702b0babae37b3e2f 100644 (file)
@@ -1871,10 +1871,12 @@ x86Decode(virCPUDefPtr cpu,
     if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
         goto cleanup;
 
-    cpu->model = cpuModel->model;
+    VIR_STEAL_PTR(cpu->model, cpuModel->model);
+    VIR_STEAL_PTR(cpu->features, cpuModel->features);
     cpu->nfeatures = cpuModel->nfeatures;
-    cpu->features = cpuModel->features;
-    VIR_FREE(cpuModel);
+    cpuModel->nfeatures = 0;
+    cpu->nfeatures_max = cpuModel->nfeatures_max;
+    cpuModel->nfeatures_max = 0;
 
     ret = 0;