[libvirt PATCH 1/2] cmdList: mark title as autofree

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

 



Fixes the (im)possible memory leak on vshTableRowAppend failure.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 tools/virsh-domain-monitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 897339b6f9..fcbc2fe9f0 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1961,7 +1961,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     bool optName = vshCommandOptBool(cmd, "name");
     bool optID = vshCommandOptBool(cmd, "id");
     size_t i;
-    char *title;
     char uuid[VIR_UUID_STRING_BUFLEN];
     int state;
     bool ret = false;
@@ -2044,6 +2043,8 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
                 state = -2;
 
             if (optTitle) {
+                g_autofree char *title = NULL;
+
                 if (!(title = virshGetDomainDescription(ctl, dom, true, 0)))
                     goto cleanup;
                 if (vshTableRowAppend(table, id_buf,
@@ -2052,7 +2053,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
                                       : virshDomainStateToString(state),
                                       title, NULL) < 0)
                     goto cleanup;
-                VIR_FREE(title);
             } else {
                 if (vshTableRowAppend(table, id_buf,
                                       virDomainGetName(dom),
-- 
2.29.2




[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