[PATCH] Fix memory leak when lookup pool list with invalid type option

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

 



There will be memory leak when lookup pool list with invalid type option
https://bugzilla.redhat.com/show_bug.cgi?id=1069068

==23060== Memcheck, a memory error detector
==23060== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==23060== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==23060== Command: virsh pool-list --type invalid
==23060==
error: Invalid pool type

==23060==
==23060== HEAP SUMMARY:
==23060==     in use at exit: 138,383 bytes in 1,559 blocks
==23060==   total heap usage: 4,199 allocs, 2,640 frees, 21,372,544 bytes allocated
==23060==
==23060== LEAK SUMMARY:
==23060==    definitely lost: 8 bytes in 1 blocks
==23060==    indirectly lost: 0 bytes in 0 blocks
==23060==      possibly lost: 0 bytes in 0 blocks
==23060==    still reachable: 138,375 bytes in 1,558 blocks
==23060==         suppressed: 0 bytes in 0 blocks
==23060== Rerun with --leak-check=full to see details of leaked memory
==23060==
==23060== For counts of detected and suppressed errors, rerun with: -v
==23060== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 6)

Signed-off-by: shyu <shyu@xxxxxxxxxx>
---
 tools/virsh-pool.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 642b078..db4d3ae 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -859,6 +859,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
         for (i = 0; i < npoolTypes; i++) {
             if ((poolType = virStoragePoolTypeFromString(poolTypes[i])) < 0) {
                 vshError(ctl, "%s", _("Invalid pool type"));
+                VIR_FREE(*poolTypes);
                 VIR_FREE(poolTypes);
                 return false;
             }
-- 
1.7.1

--
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]