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 X-Git-Tag: v2.1.0-rc1~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6ab72a9c3ad475a544ffd53a782e46a02437006;p=thirdparty%2Flibvirt.git conf: Make really sure we don't access non-existing vCPUs 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 --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 16e0736e09..db1a0ffd57 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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)