[gdk-pixbuf] Fix up gdk_pixbuf_new_from_stream_async()
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] Fix up gdk_pixbuf_new_from_stream_async()
- Date: Fri, 8 Dec 2017 19:54:17 +0000 (UTC)
commit 35e04cc3561dd429ce288ef6e48b8e5bc079bbca
Author: Benjamin Otte <otte redhat com>
Date: Wed Dec 6 19:15:48 2017 +0100
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()
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 20edeb7..3db3286 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]