summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2014-05-16 10:22:17 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2014-05-27 21:55:21 +0100
commit43a274295e59b64cbcd06f813507e61d7fbb9236 (patch)
tree2aeafe9dd2bfa9c6b540f4e5c2fc6c897a937f30
parent24b519d9b1460c7db88d08ab4e839a89d46adb3d (diff)
downloadlibgdata-43a274295e59b64cbcd06f813507e61d7fbb9236.tar.gz
core: Disconnect a cancellable in GDataDownloadStream
Ensure to disconnect from the user-provided cancellable when finalising a GDataDownloadStream. Coverity issue: #59757
-rw-r--r--gdata/gdata-download-stream.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gdata/gdata-download-stream.c b/gdata/gdata-download-stream.c
index f76a59eb..dde8f4a8 100644
--- a/gdata/gdata-download-stream.c
+++ b/gdata/gdata-download-stream.c
@@ -160,6 +160,7 @@ struct _GDataDownloadStreamPrivate {
GThread *network_thread;
GCancellable *cancellable;
GCancellable *network_cancellable; /* see the comment in gdata_download_stream_constructor() about the relationship between these two */
+ gulong network_cancellable_id;
gboolean finished;
GCond finished_cond;
@@ -352,7 +353,7 @@ gdata_download_stream_constructor (GType type, guint n_construct_params, GObject
/* Create a #GCancellable for the entire download operation if one wasn't specified for #GDataDownloadStream:cancellable during construction */
if (priv->cancellable == NULL)
priv->cancellable = g_cancellable_new ();
- g_cancellable_connect (priv->cancellable, (GCallback) cancellable_cancel_cb, priv->network_cancellable, NULL);
+ priv->network_cancellable_id = g_cancellable_connect (priv->cancellable, (GCallback) cancellable_cancel_cb, priv->network_cancellable, NULL);
/* Build the message */
_uri = soup_uri_new (priv->download_uri);
@@ -382,8 +383,15 @@ gdata_download_stream_dispose (GObject *object)
/* Block on closing the stream */
g_input_stream_close (G_INPUT_STREAM (object), NULL, NULL);
- if (priv->cancellable != NULL)
+ if (priv->cancellable != NULL) {
+ if (priv->network_cancellable_id != 0) {
+ g_cancellable_disconnect (priv->cancellable, priv->network_cancellable_id);
+ }
+
g_object_unref (priv->cancellable);
+ }
+
+ priv->network_cancellable_id = 0;
priv->cancellable = NULL;
if (priv->network_cancellable != NULL)