[gegl] jpg-load: Fix infinite hang on http:// URIs due to missing _close()
- From: Jon Nordby <jonnor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] jpg-load: Fix infinite hang on http:// URIs due to missing _close()
- Date: Mon, 10 Nov 2014 15:25:22 +0000 (UTC)
commit b12d34f2e27f05071e4ac4e1843561deca10fe25
Author: Jon Nordby <jononor gmail com>
Date: Mon Nov 10 16:24:22 2014 +0100
jpg-load: Fix infinite hang on http:// URIs due to missing _close()
Also fix leak and compile warnings
operations/external/jpg-load.c | 23 ++++++++++++++---------
1 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/operations/external/jpg-load.c b/operations/external/jpg-load.c
index f8f95b4..f241831 100644
--- a/operations/external/jpg-load.c
+++ b/operations/external/jpg-load.c
@@ -285,14 +285,18 @@ gegl_jpg_load_get_bounding_box (GeglOperation *operation)
const Babl *format = NULL;
GFile *file = NULL;
GError *err = NULL;
+ gint status = -1;
+
GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &file, &err);
if (!stream)
- return;
- const gint status = gegl_jpg_load_query_jpg (stream, &width, &height, &format);
+ return (GeglRectangle) {0, 0, 0, 0};
+ status = gegl_jpg_load_query_jpg (stream, &width, &height, &format);
+ g_input_stream_close(stream, NULL, NULL);
if (format)
gegl_operation_set_format (operation, "output", format);
+ g_object_unref(stream);
if (file) g_object_unref(file);
if (err || status)
return (GeglRectangle) {0, 0, 0, 0};
@@ -309,22 +313,23 @@ gegl_jpg_load_process (GeglOperation *operation,
GeglProperties *o = GEGL_PROPERTIES (operation);
GFile *file = NULL;
GError *err = NULL;
+ gint status = -1;
GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &file, &err);
if (!stream)
- return;
- const gint status = gegl_jpg_load_buffer_import_jpg(output, stream, 0, 0);
+ return FALSE;
+ status = gegl_jpg_load_buffer_import_jpg(output, stream, 0, 0);
+ g_input_stream_close(stream, NULL, NULL);
+
if (err)
{
g_warning ("%s failed to open file %s for reading: %s",
G_OBJECT_TYPE_NAME (operation), o->path, err->message);
- return FALSE;
- }
- if (status)
- {
+ g_object_unref(stream);
return FALSE;
}
- return TRUE;
+ g_object_unref(stream);
+ return status != 1;
}
static GeglRectangle
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]