]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Avoid dereference of NULL pointer
authorPeter Krempa <pkrempa@redhat.com>
Wed, 23 Nov 2011 14:51:28 +0000 (15:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 Nov 2011 15:19:48 +0000 (16:19 +0100)
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

index 3e755d7c24f6066d35da27dde885108ac922757e..d33d1d90766e18fb631ab2019a8625f7483c4c53 100644 (file)
@@ -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)