]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: fix invalid free
authorAlex Jia <ajia@redhat.com>
Thu, 15 Mar 2012 05:57:50 +0000 (13:57 +0800)
committerAlex Jia <ajia@redhat.com>
Thu, 15 Mar 2012 06:59:51 +0000 (14:59 +0800)
* tools/virsh.c (cmdDetachDisk): fix invalid free due to using
  uninitialised value.

* How to reproduce?
# virsh detach-disk a b
error: failed to get domain 'a'
*** glibc detected *** virsh: double free or corruption (out): 0x00007fff410ed1a0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x39cf0750c6]
/usr/lib/libvirt.so.0(virFree+0x39)[0x7f045938a239]
virsh[0x41c768]
virsh[0x415075]
virsh[0x425d64]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x39cf01ecdd]
virsh[0x40a419]
======= Memory map: ========
00400000-0044e000 r-xp 00000000 08:0e 760441                             /usr/bin/virsh
0064e000-00650000 rw-p 0004e000 08:0e 760441                             /usr/bin/virsh
......
39d7229000-39d722b000 r--p 00029000 08:0e 2183477                        /lib64/libk5crypto.so.3.1
39d722b000-39d722c000 rw-p 0002b000 08:0e 2183477                        /lib64/lAborted (core dumped)

Signed-off-by: Alex Jia <ajia@redhat.com>
tools/virsh.c

index 630b77f1041ba8f41d94c9ef31c4b834845b2d00..d45a4c917e27f10956bd0b914d0d555c5a10e10b 100644 (file)
@@ -14826,7 +14826,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
     char *disk_xml = NULL;
     virDomainPtr dom = NULL;
     const char *target = NULL;
-    char *doc;
+    char *doc = NULL;
     int ret;
     bool functionReturn = false;
     unsigned int flags;