[libvirt PATCH] util: fix double destroy / missing unref of GSource

Daniel P. Berrangé berrange at redhat.com
Tue Apr 26 14:26:51 UTC 2022


A leak of the GSource was introduced in

  commit 87a43a907f0ad4897a28ad7c216bc70f37270b93
  Author: Michal Prívozník <mprivozn at redhat.com>
  Date:   Fri Jan 28 18:42:45 2022 +0100

    lib: Use g_clear_pointer() more

As it mistakenly replaced the g_vir_source_unref call with a second
call to g_source_destroy.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/util/vireventglib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c
index fc04d8f712..3cc42597fd 100644
--- a/src/util/vireventglib.c
+++ b/src/util/vireventglib.c
@@ -227,7 +227,7 @@ virEventGLibHandleUpdate(int watch,
             goto cleanup;
 
         VIR_DEBUG("Removed old handle source=%p", data->source);
-        g_source_destroy(data->source);
+        vir_g_source_unref(data->source, NULL);
         g_clear_pointer(&data->source, g_source_destroy);
         data->events = 0;
     }
-- 
2.35.1



More information about the libvir-list mailing list