From: Martin Kletzander Date: Tue, 12 Jul 2016 11:44:10 +0000 (+0200) Subject: conf: Make really sure we don't access non-existing vCPUs again X-Git-Tag: v2.1.0-rc1~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05f89657eed52550050f9308bb7cb8d56dde9cd0;p=thirdparty%2Flibvirt.git conf: Make really sure we don't access non-existing vCPUs again 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 --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index db1a0ffd57..1fd826dd85 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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;