virsh capabilities cmd: plug a leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's another:

  $ valgrind --leak-check=full \
    ./virsh --connect test://$PWD/../docs/testnode.xml capabilities
  ...
  ==16392== 368 bytes in 1 blocks are definitely lost in loss record 13 of 27
  ==16392==    at 0x4A059F6: malloc (vg_replace_malloc.c:149)
  ==16392==    by 0x387BC7CC11: strdup (strdup.c:43)
  ==16392==    by 0x4194D2: testGetCapabilities (test.c:1006)
  ==16392==    by 0x412B43: virConnectGetCapabilities (libvirt.c:2119)
  ==16392==    by 0x408047: cmdCapabilities (virsh.c:2018)
  ==16392==    by 0x40C5F9: vshCommandRun (virsh.c:4032)
  ==16392==    by 0x40E6AF: main (virsh.c:4991)
  ==16392==

Here's the patch:

	* src/virsh.c (cmdCapabilities): Plug a small leak.

diff --git a/src/virsh.c b/src/virsh.c
index c09dc8d..0d93fb6 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -2020,6 +2020,7 @@ cmdCapabilities (vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
         return FALSE;
     }
     vshPrint (ctl, "%s\n", caps);
+    free (caps);

     return TRUE;
 }
--
1.5.4.rc5.1.g0fa73

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]