diff options
author | Benjamin Otte <otte@redhat.com> | 2017-12-06 19:15:48 +0100 |
---|---|---|
committer | Debarshi Ray <debarshir@gnome.org> | 2017-12-08 20:54:01 +0100 |
commit | 35e04cc3561dd429ce288ef6e48b8e5bc079bbca (patch) | |
tree | 3b942e46b20a042621a6264d89c1931ed38d09f4 /gdk-pixbuf | |
parent | bd1510f9b5d42eedd81bd1ad059837ee4ab06397 (diff) | |
download | gdk-pixbuf-35e04cc3561dd429ce288ef6e48b8e5bc079bbca.tar.gz |
Fix up gdk_pixbuf_new_from_stream_async()
Add fixes for the various issues brought up in
https://bugzilla.gnome.org/show_bug.cgi?id=790584
* g_task_propagate_pointer() is transfer full
* GBytes get leaked
* always pass the stream as task source object to avoid criticals
* don't check the source object in finish()
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 20edeb725..3db328656 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -1560,8 +1560,10 @@ load_from_stream_async_cb (GObject *stream, gdk_pixbuf_loader_close (loader, NULL); g_task_return_error (task, error); g_object_unref (task); + g_bytes_unref (bytes); return; } + g_bytes_unref (bytes); g_input_stream_read_bytes_async (G_INPUT_STREAM (stream), LOAD_BUFFER_SIZE, G_PRIORITY_DEFAULT, @@ -1836,7 +1838,7 @@ gdk_pixbuf_new_from_stream_async (GInputStream *stream, g_return_if_fail (callback != NULL); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); - task = g_task_new (NULL, cancellable, callback, user_data); + task = g_task_new (stream, cancellable, callback, user_data); g_task_set_source_tag (task, gdk_pixbuf_new_from_stream_async); g_task_set_task_data (task, gdk_pixbuf_loader_new (), g_object_unref); @@ -1866,9 +1868,8 @@ gdk_pixbuf_new_from_stream_finish (GAsyncResult *async_result, GError **error) { GTask *task; - GdkPixbuf *result; - g_return_val_if_fail (g_task_is_valid (async_result, NULL), NULL); + g_return_val_if_fail (G_IS_TASK (async_result), NULL); g_return_val_if_fail (!error || (error && !*error), NULL); task = G_TASK (async_result); @@ -1876,10 +1877,7 @@ gdk_pixbuf_new_from_stream_finish (GAsyncResult *async_result, g_warn_if_fail (g_task_get_source_tag (task) == gdk_pixbuf_new_from_stream_async || g_task_get_source_tag (task) == gdk_pixbuf_new_from_stream_at_scale_async); - result = g_task_propagate_pointer (task, error); - if (result) - g_object_ref (result); - return result; + return g_task_propagate_pointer (task, error); } static void |