[libgdata/libgdata-0-7] documents: Disconnect from the content-type notification signal
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-7] documents: Disconnect from the content-type notification signal
- Date: Fri, 10 Dec 2010 22:40:53 +0000 (UTC)
commit 1e5349545689cc02bd5d559fd982fc5755c0b85f
Author: Philip Withnall <philip tecnocode co uk>
Date: Fri Dec 10 22:35:57 2010 +0000
documents: Disconnect from the content-type notification signal
We can't change GDataDownloadStream to emit notification signals for
content-type in the download thread in the 0.7 branch, since that would be
an API break. This means that the notifications could potentially be
delivered after gdata_documents_document_download() returns. Since the
closure for the notification idle function maintains a reference to the
GDataDownloadStream, this means that the signal handler won't be disconnected
automatically once the GDataDownloadStream is unreffed in
gdata_documents_document_download(). Consequently, it's possible to get
invalid writes into random bits of memory unless we disconnect from the
content-type notification signal. This commit does that.
.../services/documents/gdata-documents-document.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/gdata/services/documents/gdata-documents-document.c b/gdata/services/documents/gdata-documents-document.c
index fae49e6..3359113 100644
--- a/gdata/services/documents/gdata-documents-document.c
+++ b/gdata/services/documents/gdata-documents-document.c
@@ -110,6 +110,7 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
GInputStream *src_stream;
GFile *output_file = NULL;
GError *child_error = NULL;
+ gulong content_type_signal = 0;
/* TODO: async version */
g_return_val_if_fail (GDATA_IS_DOCUMENTS_DOCUMENT (self), NULL);
@@ -152,8 +153,13 @@ gdata_documents_document_download (GDataDocumentsDocument *self, GDataDocumentsS
src_stream = gdata_download_stream_new (_service, download_uri);
if (content_type != NULL)
g_signal_connect (src_stream, "notify::content-type", (GCallback) notify_content_type_cb, content_type);
+
g_output_stream_splice (G_OUTPUT_STREAM (dest_stream), src_stream, G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
cancellable, &child_error);
+
+ if (content_type_signal != 0)
+ g_signal_handler_disconnect (src_stream, content_type_signal);
+
g_object_unref (src_stream);
g_object_unref (dest_stream);
g_free (download_uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]