From c4b32641f10ec7cd94f907f453b9b6616e6acab9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 23 Nov 2011 15:51:28 +0100 Subject: [PATCH] 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. --- src/qemu/qemu_domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- 2.39.5