]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vbox_tmpl.c: avoid NULL deref upon vboxDomainCreateXML failure
authorJim Meyering <meyering@redhat.com>
Wed, 16 Dec 2009 12:56:57 +0000 (13:56 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 5 Jan 2010 17:14:44 +0000 (18:14 +0100)
* src/vbox/vbox_tmpl.c (vboxDomainCreateXML): Don't call
vboxDomainUndefine on a NULL "dom".

src/vbox/vbox_tmpl.c

index 5a1d8dcbb771422dc4253f4c2309c0972af01e91..5889f32d3f8815c338fce39c5b84e4b636e24e47 100644 (file)
@@ -990,8 +990,6 @@ cleanup:
 
 static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
                                         unsigned int flags ATTRIBUTE_UNUSED) {
-    virDomainPtr dom = NULL;
-
     /* VirtualBox currently doesn't have support for running
      * virtual machines without actually defining them and thus
      * for time being just define new machine and start it.
@@ -1000,19 +998,16 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
      * change this behaviour to the expected one.
      */
 
-    dom = vboxDomainDefineXML(conn, xml);
-    if (dom) {
-        if (vboxDomainCreate(dom) < 0)
-            goto cleanup;
-    } else {
-        goto cleanup;
+    virDomainPtr dom = vboxDomainDefineXML(conn, xml);
+    if (dom == NULL)
+        return NULL;
+
+    if (vboxDomainCreate(dom) < 0) {
+        vboxDomainUndefine(dom);
+        return NULL;
     }
 
     return dom;
-
-cleanup:
-    vboxDomainUndefine(dom);
-    return NULL;
 }
 
 static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {