summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2015-07-22 04:09:32 +0200
committerFabiano FidĂȘncio <fidencio@redhat.com>2016-01-05 21:28:43 +0100
commit25b1daf7984b7c357513e6a52a0d70d165e6a870 (patch)
tree019e364db44794a375be9a48b7170be23b1d757c
parent53642b9e5e146d09a17749495b9a856c9afbf140 (diff)
events: don't leak GIOChannel when destroying IO handle
virt_viewer_events_add_handle() creates a GIOChannel in order to watch the fd it was given for changes. virt_viewer_events_remove_handle() is freeing all the resources allocated by virt_viewer_events_add_handle() except for this GIOChannel. This commit adds the needed g_io_channel_unref() call to virt_viewer_events_remove_handle() Based on commit 8e95b8d25a3eee6316aff2f83b0c449aaf10984a from libvirt-glib. Original author: Christophe Fergeau <cfergeau@redhat.com> Related to: rhbz#1243228 (cherry picked from commit b225ef5884214763ae5650202ebbc914ba77f224)
-rw-r--r--src/virt-viewer-events.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/virt-viewer-events.c b/src/virt-viewer-events.c
index 44740c3..9636e3e 100644
--- a/src/virt-viewer-events.c
+++ b/src/virt-viewer-events.c
@@ -239,6 +239,10 @@ virt_viewer_events_remove_handle(int watch)
data->events = 0;
}
+ g_warn_if_fail(data->channel != NULL);
+ g_io_channel_unref(data->channel);
+ data->channel = NULL;
+
/* since the actual watch deletion is done asynchronously, a update_handle call may
* reschedule the watch before it's fully deleted, that's why we need to mark it as
* 'removed' to prevent reuse