[PATCH 03/18] vshCommandParse: Don't leak @tkdata

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

 



When parsing cmd line which has "--" on it, this is leaked.
Problem is, parser->getNextArg() allocates new string and stores
it into tkdata. But as soon as "--" is detected 'continue' is
issued without any free of the allocated memory.

  ==5304== 3 bytes in 1 blocks are definitely lost in loss record 1 of 782
  ==5304==    at 0x4C2AF50: malloc (vg_replace_malloc.c:299)
  ==5304==    by 0x8BB5AA9: strdup (strdup.c:42)
  ==5304==    by 0x55842CA: virStrdup (virstring.c:941)
  ==5304==    by 0x172B21: _vshStrdup (vsh.c:162)
  ==5304==    by 0x175E8E: vshCommandArgvGetArg (vsh.c:1622)
  ==5304==    by 0x17551D: vshCommandParse (vsh.c:1418)
  ==5304==    by 0x175F25: vshCommandArgvParse (vsh.c:1638)
  ==5304==    by 0x130940: virshParseArgv (virsh.c:820)
  ==5304==    by 0x130C49: main (virsh.c:922)

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tools/vsh.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/vsh.c b/tools/vsh.c
index a21e1d1de..2366b7b71 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1491,6 +1491,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
                 }
             } else if (tkdata[0] == '-' && tkdata[1] == '-' &&
                        tkdata[2] == '\0') {
+                VIR_FREE(tkdata);
                 data_only = true;
                 continue;
             } else {
-- 
2.13.6

--
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]
  Powered by Linux