]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Avoid segfault of libvirt_lxc helper on early cleanup paths
authorPeter Krempa <pkrempa@redhat.com>
Mon, 26 Nov 2012 11:13:56 +0000 (12:13 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Nov 2012 14:48:31 +0000 (15:48 +0100)
Early jumps to the cleanup label caused a crash of the libvirt_lxc
container helper as the cleanup section called
virLXCControllerDeleteInterfaces(ctrl) without checking the ctrl argument
for NULL. The argument was de-referenced soon after.

$ /usr/libexec/libvirt_lxc
/usr/libexec/libvirt_lxc: missing --name argument for configuration
Segmentation fault

src/lxc/lxc_controller.c

index a9d2d4045f120e587b2b2a63d459a39d21ef62f6..ea5bc5819cef11194e3409588fdde7daf548181e 100644 (file)
@@ -1672,7 +1672,8 @@ int main(int argc, char *argv[])
 
 cleanup:
     virPidFileDelete(LXC_STATE_DIR, name);
-    virLXCControllerDeleteInterfaces(ctrl);
+    if (ctrl)
+        virLXCControllerDeleteInterfaces(ctrl);
     for (i = 0 ; i < nttyFDs ; i++)
         VIR_FORCE_CLOSE(ttyFDs[i]);
     VIR_FREE(ttyFDs);