[gdk-pixbuf] io: Fix GError leak in gdk_pixbuf_new_from_stream()
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] io: Fix GError leak in gdk_pixbuf_new_from_stream()
- Date: Thu, 27 Jul 2017 11:36:44 +0000 (UTC)
commit 3428b6d710bcd1ba5f8feb1346ed424dbf708c25
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Jun 8 15:37:29 2017 +1200
io: Fix GError leak in gdk_pixbuf_new_from_stream()
https://bugzilla.gnome.org/show_bug.cgi?id=783538
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 1669815..c031922 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]