]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: Fix memory leak of fds
authorPeng Liang <liangpeng10@huawei.com>
Wed, 2 Mar 2022 09:22:05 +0000 (17:22 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 4 Mar 2022 09:53:03 +0000 (10:53 +0100)
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>
src/rpc/virnetserver.c

index ad581a36ddf33c0bdf2b038c8acf781b086797a2..d9430a2cfa7619f27fb7cafcd5923ae5dfe08150 100644 (file)
@@ -655,7 +655,7 @@ virNetServerAddServiceActivation(virNetServer *srv,
                                  size_t max_queued_clients,
                                  size_t nrequests_client_max)
 {
-    int *fds;
+    g_autofree int *fds = NULL;
     size_t nfds;
 
     if (act == NULL)