From: Peter Krempa Date: Wed, 23 Nov 2011 14:51:28 +0000 (+0100) Subject: qemu: Avoid dereference of NULL pointer X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c4b32641f10ec7cd94f907f453b9b6616e6acab9;p=libvirt.git qemu: Avoid dereference of NULL pointer If something fails while initializing qemu job object in qemuDomainObjPrivateAlloc(), memory to the private pointer is freed, but after that, the pointer is still dereferenced, which may result in a segfault. * qemuDomainObjPrivateAlloc() - Don't dereference NULL pointer. --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3e755d7c24..d33d1d9076 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -214,11 +214,15 @@ static void *qemuDomainObjPrivateAlloc(void) return NULL; if (qemuDomainObjInitJob(priv) < 0) - VIR_FREE(priv); + goto error; priv->migMaxBandwidth = QEMU_DOMAIN_DEFAULT_MIG_BANDWIDTH_MAX; return priv; + +error: + VIR_FREE(priv); + return NULL; } static void qemuDomainObjPrivateFree(void *data)