vsh: Free commands in vshDeinit()

Whether virsh/virt-admin is running in interactive or
non-interactive mode, vshControl::cmd contains the batch of last
executed commands as a linked list. Just look into
vshCommandParse(). Free the linked list in vshDeinit() to avoid
memleak.

  3,312 bytes in 3 blocks are still reachable in loss record 572 of 577
     at 0x484CEF3: calloc (vg_replace_malloc.c:1675)
     by 0x506AB29: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8200.5)
     by 0x1B74B8: vshCmdNew (vsh.c:1466)
     by 0x1B7A80: vshCommandParse (vsh.c:1615)
     by 0x1B8458: vshCommandStringParse (vsh.c:1874)
     by 0x1419C1: virshParseArgv (virsh.c:773)
     by 0x141D11: main (virsh.c:879)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik committed 2025-04-14 12:00:48 +02:00
1 parent 32fb9af277
commit 9e89ef3f2f
1 file changed
+1
+1
View File
@@ -3204,6 +3204,7 @@ vshDeinit(vshControl *ctl)
* interactive mode. */
vshReadlineDeinit(ctl);
vshCloseLogFile(ctl);
g_clear_pointer(&ctl->cmd, vshCommandFree);
}
/* -----------------------------------------------