From 362dc49e04dfef23a2aaf4c2db04252a859dadde Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 10 Mar 2014 16:57:50 +0000 Subject: TpContact: mime_file_written: don't leak the file's path Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76000 Reviewed-by: Guillaume Desmottes --- telepathy-glib/contact.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index 4a77f1137..e747e210b 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -2797,21 +2797,23 @@ mime_file_written (GObject *source_object, WriteAvatarData *avatar_data = user_data; GFile *file = G_FILE (source_object); TpContact *self; + gchar *path = g_file_get_path (file); g_assert (file == avatar_data->mime_file); if (!g_file_replace_contents_finish (file, res, NULL, &error)) { - DEBUG ("Failed to store MIME type in cache (%s): %s", - g_file_get_path (file), error->message); + DEBUG ("Failed to store MIME type in cache (%s): %s", path, + error->message); g_clear_error (&error); } else { - DEBUG ("Contact avatar MIME type stored in cache: %s", - g_file_get_path (file)); + DEBUG ("Contact avatar MIME type stored in cache: %s", path); } + g_free (path); + self = g_weak_ref_get (&avatar_data->contact); if (self == NULL) -- cgit v1.2.1 From d1b1f0bf72a2820ae5a51b25c7817c3005b687ab Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 10 Mar 2014 17:30:44 +0000 Subject: TpProxy: finish_all_requests: don't leak copied GQueue Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76000 Reviewed-by: Guillaume Desmottes --- telepathy-glib/proxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telepathy-glib/proxy.c b/telepathy-glib/proxy.c index 8d6befbf4..f7a5a0efc 100644 --- a/telepathy-glib/proxy.c +++ b/telepathy-glib/proxy.c @@ -2208,7 +2208,7 @@ finish_all_requests (TpProxy *self, tp_proxy_prepare_request_finish (iter->data, error); } - g_queue_clear (tmp); + g_queue_free (tmp); } /* -- cgit v1.2.1 From b80309ee68dc9003d6384d6932d89c1443cdc8a1 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 4 Dec 2013 14:09:18 -0500 Subject: TpFileTransferChannel: Fix possible crashes, particularly with GLib 2.39 tp_file_transfer_channel_accept_file_async() and tp_file_transfer_channel_provide_file_async() operations are supposed to complete as soon as the CM returns from AcceptFile or ProvideFile. That means that we cannot call operation_failed() for streaming errors. We also have to keep a ref on self while streaming the file to avoid a crash in the callback when we dereference self. This means that the client app cannot cancel the ongoing streaming by unreffing the channel, replying on dispose calling g_cancellable_cancel(). It can still be doing using g_object_run_dispose() though. To make it cleaner we should probably add tp_file_transfer_channel_cancel(). The spec does not provide any way for the streaming client to inform the CM and other clients about the error occured while streaming. TpFileTransferChannel API does not even have a way to propagate that error to the user. [slightly more informative commit message for the 0.22 cherry-pick -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72319 --- telepathy-glib/file-transfer-channel.c | 37 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c index d3067da90..f74a297e4 100644 --- a/telepathy-glib/file-transfer-channel.c +++ b/telepathy-glib/file-transfer-channel.c @@ -184,6 +184,7 @@ static void operation_failed (TpFileTransferChannel *self, GError *error) { + g_assert (self->priv->result != NULL); g_simple_async_result_take_error (self->priv->result, error); g_simple_async_result_complete_in_idle (self->priv->result); tp_clear_object (&self->priv->result); @@ -202,12 +203,11 @@ stream_close_cb (GObject *source, { DEBUG ("Failed to close stream: %s\n", error->message); g_clear_error (&error); - /* Don't fail the accept/provide operation as this is just a - * close operation. */ } /* Now that this is closed in both ways, let's just remove it. */ g_clear_object (&self->priv->stream); + g_object_unref (self); } static void @@ -222,13 +222,13 @@ splice_stream_ready_cb (GObject *output, &error); if (error != NULL && !g_cancellable_is_cancelled (self->priv->cancellable)) - { - DEBUG ("splice operation failed: %s", error->message); - operation_failed (self, error); - } + DEBUG ("splice operation failed: %s", error->message); + g_clear_error (&error); g_io_stream_close_async (self->priv->stream, G_PRIORITY_DEFAULT, - NULL, stream_close_cb, self); + NULL, stream_close_cb, g_object_ref (self)); + + g_object_unref (self); } static void @@ -241,10 +241,7 @@ client_socket_connected (TpFileTransferChannel *self) self->priv->client_socket); if (conn == NULL) { - error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, - "Failed to create client connection"); - DEBUG ("%s", error->message); - operation_failed (self, error); + DEBUG ("Failed to create client connection"); return; } @@ -262,9 +259,8 @@ client_socket_connected (TpFileTransferChannel *self) conn, byte, NULL, &error)) { DEBUG ("Failed to send credentials: %s", error->message); - - operation_failed (self, error); g_object_unref (conn); + g_clear_error (&error); return; } } @@ -282,7 +278,7 @@ client_socket_connected (TpFileTransferChannel *self) G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, G_PRIORITY_DEFAULT, self->priv->cancellable, - splice_stream_ready_cb, self); + splice_stream_ready_cb, g_object_ref (self)); } else { @@ -294,7 +290,7 @@ client_socket_connected (TpFileTransferChannel *self) G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET, G_PRIORITY_DEFAULT, self->priv->cancellable, - splice_stream_ready_cb, self); + splice_stream_ready_cb, g_object_ref (self)); } } @@ -308,8 +304,7 @@ client_socket_cb (GSocket *socket, if (!g_socket_check_connect_result (socket, &error)) { DEBUG ("Failed to connect to socket: %s", error->message); - - operation_failed (self, error); + g_clear_error (&error); return FALSE; } @@ -1122,8 +1117,8 @@ start_transfer (TpFileTransferChannel *self) NULL); g_source_attach (source, g_main_context_get_thread_default ()); - g_source_set_callback (source, (GSourceFunc) client_socket_cb, self, - NULL); + g_source_set_callback (source, (GSourceFunc) client_socket_cb, + g_object_ref (self), g_object_unref); g_error_free (error); g_source_unref (source); @@ -1131,8 +1126,7 @@ start_transfer (TpFileTransferChannel *self) else { DEBUG ("Failed to connect to socket: %s:", error->message); - - operation_failed (self, error); + g_clear_error (&error); } } @@ -1171,6 +1165,7 @@ accept_or_provide_file_cb (TpChannel *proxy, } g_simple_async_result_complete_in_idle (self->priv->result); + g_clear_object (&self->priv->result); } static gboolean -- cgit v1.2.1 From 3d96ce6954390613bf19bf8e5cf28ab1957717f2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 13 Mar 2014 13:49:01 +0000 Subject: 0.22 NEWS --- NEWS | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 5bc482bb7..389cdc736 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,15 @@ telepathy-glib 0.22.2 (UNRELEASED) ================================== -... +Fixes: + +• clean up file transfer error handling to fix a crash frequently seen + under GLib 2.39 (fd.o #72319, Xavier) + +• fix a memory leak when cleaning up TpProxy "prepare" requests + (fd.o #76000, Simon) + +• fix a memory leak for paths to contacts' avatar data (fd.o #76000, Simon) telepathy-glib 0.22.1 (2014-01-29) ================================== -- cgit v1.2.1