]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Make really sure we don't access non-existing vCPUs
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 12 Jul 2016 11:44:10 +0000 (13:44 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 13 Jul 2016 12:23:14 +0000 (14:23 +0200)
MinGW complained that we might be dereferencing a NULL pointer.  While
that can't be true, the logic certainly allows for that.

src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper':
src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference]
         if (vcpu->cpumask)
              ~~~~^~~~~~~~~

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/conf/domain_conf.c

index 16e0736e09dbcde1d09b0f3f77cbec92c3d61348..db1a0ffd57b652b65971e727a324e0fee15212d1 100644 (file)
@@ -1542,7 +1542,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
         virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);
         virBitmapPtr bitmap = NULL;
 
-        if (vcpu->cpumask)
+        if (vcpu && vcpu->cpumask)
             bitmap = vcpu->cpumask;
         else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
                  autoCpuset)