diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2017-06-08 15:37:29 +1200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2017-07-27 12:36:20 +0100 |
commit | 3428b6d710bcd1ba5f8feb1346ed424dbf708c25 (patch) | |
tree | 680c6d82829773937be174aaa37d3dbcb8306dd3 /gdk-pixbuf | |
parent | bb5492e3360eec136525677072ca292ec94f7193 (diff) | |
download | gdk-pixbuf-3428b6d710bcd1ba5f8feb1346ed424dbf708c25.tar.gz |
io: Fix GError leak in gdk_pixbuf_new_from_stream()
https://bugzilla.gnome.org/show_bug.cgi?id=783538
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 166981574..c03192244 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -1433,9 +1433,7 @@ load_from_stream (GdkPixbufLoader *loader, GdkPixbuf *pixbuf; gssize n_read; guchar buffer[LOAD_BUFFER_SIZE]; - gboolean res; - res = TRUE; while (1) { n_read = g_input_stream_read (stream, buffer, @@ -1443,9 +1441,8 @@ load_from_stream (GdkPixbufLoader *loader, cancellable, error); if (n_read < 0) { - res = FALSE; - error = NULL; /* Ignore further errors */ - break; + gdk_pixbuf_loader_close (loader, NULL); + return NULL; } if (n_read == 0) @@ -1455,25 +1452,19 @@ load_from_stream (GdkPixbufLoader *loader, buffer, n_read, error)) { - res = FALSE; - error = NULL; - break; + gdk_pixbuf_loader_close (loader, NULL); + return NULL; } } - if (!gdk_pixbuf_loader_close (loader, error)) { - res = FALSE; - error = NULL; - } + if (!gdk_pixbuf_loader_close (loader, error)) + return NULL; - pixbuf = NULL; - if (res) { - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) - g_object_ref (pixbuf); - } + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + if (pixbuf == NULL) + return NULL; - return pixbuf; + return g_object_ref (pixbuf); } |