From 640e987b61810546bf3e48b12b710d3d224b1e16 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 14 Jun 2021 14:56:15 +0200 Subject: [PATCH] remote: dispatch: Don't use virStringListFreeCount for NULL terminated lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both virDomainAuthorizedSSHKeysGet and virDomainGetMessages return a NULL-terminated string-list, so we can use g_auto(GStrv) to clear the used memory on failures. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/remote/remote_daemon_dispatch.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 0e38b314a2..0bac7d4f51 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -7327,7 +7327,7 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer *server G_GNUC_UNUSED, int rv = -1; virConnectPtr conn = remoteGetHypervisorConn(client); int nkeys = 0; - char **keys = NULL; + g_auto(GStrv) keys = NULL; virDomainPtr dom = NULL; if (!conn) @@ -7355,8 +7355,6 @@ remoteDispatchDomainAuthorizedSshKeysGet(virNetServer *server G_GNUC_UNUSED, cleanup: if (rv < 0) virNetMessageSaveError(rerr); - if (nkeys > 0) - virStringListFreeCount(keys, nkeys); virObjectUnref(dom); return rv; @@ -7409,7 +7407,7 @@ remoteDispatchDomainGetMessages(virNetServer *server G_GNUC_UNUSED, int rv = -1; virConnectPtr conn = remoteGetHypervisorConn(client); int nmsgs = 0; - char **msgs = NULL; + g_auto(GStrv) msgs = NULL; virDomainPtr dom = NULL; if (!conn) @@ -7436,8 +7434,6 @@ remoteDispatchDomainGetMessages(virNetServer *server G_GNUC_UNUSED, cleanup: if (rv < 0) virNetMessageSaveError(rerr); - if (nmsgs > 0) - virStringListFreeCount(msgs, nmsgs); virObjectUnref(dom); return rv;