From 88ddb9ae6bc020c5ce64f98a6a8e5823f48c885a Mon Sep 17 00:00:00 2001
From: Peng Liang <liangpeng10@huawei.com>
Date: Wed, 2 Mar 2022 17:22:05 +0800
Subject: [PATCH 108/108] rpc: Fix memory leak of fds

In virSystemdActivationClaimFDs, the memory of ent->fds has been stolen
and stored in fds, but fds is never freed, which causes a memory leak.
Fix it by declaring fds as g_autofree.

Reported-by: Jie Tang <tangjie18@huawei.com>
Signed-off-by: Peng Liang <liangpeng10@huawei.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 8a1915c4d6c33669dcb390d0708cb6e5d651770d)
---
 src/rpc/virnetserver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 242052754f..26f3a5ec31 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -683,7 +683,7 @@ virNetServerAddServiceActivation(virNetServerPtr srv,
                                  size_t max_queued_clients,
                                  size_t nrequests_client_max)
 {
-    int *fds;
+    g_autofree int *fds = NULL;
     size_t nfds;
 
     if (act == NULL)
-- 
2.33.0

