[libvirt PATCH 1/2] cmdList: mark title as autofree
Ján Tomko
jtomko at redhat.com
Mon Mar 15 15:46:07 UTC 2021
Fixes the (im)possible memory leak on vshTableRowAppend failure.
Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
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
More information about the libvir-list
mailing list