]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Free commands in vshDeinit()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Apr 2025 14:34:50 +0000 (16:34 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 14 Apr 2025 10:00:48 +0000 (12:00 +0200)
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>
tools/vsh.c

index b42e2f0c5046d62867614bd11c79265e7a8cd776..d1e699505b9118ec16dd48a9b6d3abd9e7fc1aa8 100644 (file)
@@ -3204,6 +3204,7 @@ vshDeinit(vshControl *ctl)
      * interactive mode. */
     vshReadlineDeinit(ctl);
     vshCloseLogFile(ctl);
+    g_clear_pointer(&ctl->cmd, vshCommandFree);
 }
 
 /* -----------------------------------------------