aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2011-08-24 06:42:52 +0800
committerPhilip Withnall <philip@tecnocode.co.uk>2011-08-24 06:47:23 +0800
commit57075092737c287010e1a2435bf1b1c1839101a5 (patch)
tree8d1634a759475bb65d9b29ad428ac7d2683abab7 /libempathy-gtk/empathy-ui-utils.c
parent4fd99e6dc16c26656d43296f2b3104dac3f9e45b (diff)
downloadgsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar.gz
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar.bz2
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar.lz
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar.xz
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.tar.zst
gsoc2013-empathy-57075092737c287010e1a2435bf1b1c1839101a5.zip
libempathy-gtk: Explicitly close the input stream used for reading avatars
Due to a missing unref in GIO, the input stream is leaked by GFileIcon, so if we rely on its FD being implicitly closed when the stream is finalised, we'll end up leaking (lots of) file descriptors. As well as fixing the unref in GIO (see: bgo#657206), we now explicitly close the input stream so that even if the stream object is leaked, the FD isn't. Closes: bgo#656682
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 060e0aab5..2a4b86781 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -566,6 +566,21 @@ pixbuf_avatar_from_individual_closure_free (
}
static void
+avatar_icon_load_close_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ g_input_stream_close_finish (G_INPUT_STREAM (object), result, &error);
+
+ if (error != NULL) {
+ DEBUG ("Failed to close pixbuf stream: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static void
avatar_icon_load_read_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -607,6 +622,11 @@ avatar_icon_load_read_cb (GObject *object,
avatar_pixbuf_from_loader (closure->loader),
g_object_unref);
+ /* Close the file for safety (even though it should be
+ * automatically closed when the stream is finalised). */
+ g_input_stream_close_async (stream, G_PRIORITY_DEFAULT, NULL,
+ (GAsyncReadyCallback) avatar_icon_load_close_cb, NULL);
+
goto out;
} else {
/* Loop round and read another chunk. */