]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Make really sure we don't access non-existing vCPUs again
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 12 Jul 2016 11:44:10 +0000 (13:44 +0200)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 13 Jul 2016 16:55:50 +0000 (17:55 +0100)
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 'virDomainDefPostParse':
../../src/conf/domain_conf.c:4224:18: error: potential null pointer dereference [-Werror=null-dereference]
         if (!vcpu->online && vcpu->cpumask) {
              ~~~~^~~~~~~~

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/conf/domain_conf.c

index db1a0ffd57b652b65971e727a324e0fee15212d1..1fd826dd859a57ac531ee60ac42c02db09682278 100644 (file)
@@ -4221,7 +4221,7 @@ virDomainDefRemoveOfflineVcpuPin(virDomainDefPtr def)
     for (i = 0; i < virDomainDefGetVcpusMax(def); i++) {
         vcpu = virDomainDefGetVcpu(def, i);
 
-        if (!vcpu->online && vcpu->cpumask) {
+        if (vcpu && !vcpu->online && vcpu->cpumask) {
             virBitmapFree(vcpu->cpumask);
             vcpu->cpumask = NULL;