[Spice-devel] [spice-gtk 2/3] wocky: Set ConnectAsyncData instance as GTask data

Christophe Fergeau cfergeau at redhat.com
Wed Aug 3 07:49:52 UTC 2016


Currently, the ConnectAsyncData instance is leaked if for example
we trigger one codepath calling g_task_return_error(). If we
associate it with the GTask with g_task_set_task_data(),
this kind of leak will be avoided.
---
 src/wocky-http-proxy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
index d1519b8..cf51ba3 100644
--- a/src/wocky-http-proxy.c
+++ b/src/wocky-http-proxy.c
@@ -363,6 +363,8 @@ wocky_http_proxy_connect_async (GProxy *proxy,
   data->length = strlen (data->buffer);
   data->offset = 0;
 
+  g_task_set_task_data (task, data, (GDestroyNotify)free_connect_data);
+
   if (WOCKY_IS_HTTPS_PROXY (proxy))
     {
       GError *error = NULL;
@@ -456,7 +458,6 @@ reply_read_cb (GObject *source,
 
   g_task_return_pointer (data->task, data->io_stream, (GDestroyNotify) g_object_unref);
   data->io_stream = NULL;
-  free_connect_data (data);
   g_object_unref (data->task);
 }
 
-- 
2.7.4



More information about the Spice-devel mailing list