mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
remote: dispatch: Don't use virStringListFreeCount for NULL terminated lists
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 <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
7f58028c2b
commit
640e987b61
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user