summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-07-17 02:37:29 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-07-17 02:37:29 +0000
commitc48afeca8a7dcfdd397afbe1b11996af82cbaf9f (patch)
tree8aa7518753efb95cbabb2fa9dc9c848ff42c9ffc /gdk-pixbuf
parentb8b28b6782d19b3e7657df9e7484550a7035a01c (diff)
downloadgtk+-c48afeca8a7dcfdd397afbe1b11996af82cbaf9f.tar.gz
Put the code to protect against broken loaders that forget to set error in
2006-07-16 Matthias Clasen <mclasen@redhat.com> * gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module) (gdk_pixbuf_loader_write, gdk_pixbuf_loader_close) (gdk_pixbuf_loader_ensure_error): Put the code to protect against broken loaders that forget to set error in an auxiliary function and call it in more places. (#346428, Catmur)
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog7
-rw-r--r--gdk-pixbuf/gdk-pixbuf-loader.c64
2 files changed, 39 insertions, 32 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index a0624ad311..f6d8bb9c42 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,5 +1,12 @@
2006-07-16 Matthias Clasen <mclasen@redhat.com>
+ * gdk-pixbuf-loader.c (gdk_pixbuf_loader_load_module)
+ (gdk_pixbuf_loader_write, gdk_pixbuf_loader_close)
+ (gdk_pixbuf_loader_ensure_error): Put the code to protect
+ against broken loaders that forget to set error in an
+ auxiliary function and call it in more places. (#346428,
+ Catmur)
+
* io-xbm.c: Fix incremental loading of
xbms. (#346427, Ed Catmur)
Also make the xbm loader accept const variations.
diff --git a/gdk-pixbuf/gdk-pixbuf-loader.c b/gdk-pixbuf/gdk-pixbuf-loader.c
index 86702c91ee..b03f06e83e 100644
--- a/gdk-pixbuf/gdk-pixbuf-loader.c
+++ b/gdk-pixbuf/gdk-pixbuf-loader.c
@@ -303,6 +303,27 @@ gdk_pixbuf_loader_update (GdkPixbuf *pixbuf,
MIN (height, gdk_pixbuf_animation_get_height (priv->animation)));
}
+/* Defense against broken loaders; DO NOT take this as a GError example! */
+static void
+gdk_pixbuf_loader_ensure_error (GdkPixbufLoader *loader,
+ GError **error)
+{
+ GdkPixbufLoaderPrivate *priv = loader->priv;
+
+ if (error == NULL || *error != NULL)
+ return;
+
+ g_warning ("Bug! loader '%s' didn't set an error on failure",
+ priv->image_module->module_name);
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_FAILED,
+ _("Internal error: Image loader module '%s' failed to"
+ " complete an operation, but didn't give a reason for"
+ " the failure"),
+ priv->image_module->module_name);
+}
+
static gint
gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader,
const char *image_type,
@@ -358,23 +379,7 @@ gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader,
if (priv->context == NULL)
{
- /* Defense against broken loaders; DO NOT take this as a GError
- * example
- */
- if (error && *error == NULL)
- {
- g_warning ("Bug! loader '%s' didn't set an error on failure",
- priv->image_module->module_name);
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_FAILED,
- _("Internal error: Image loader module '%s'"
- " failed to begin loading an image, but didn't"
- " give a reason for the failure"),
- priv->image_module->module_name);
-
- }
-
+ gdk_pixbuf_loader_ensure_error (loader, error);
return 0;
}
@@ -450,7 +455,10 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
eaten = gdk_pixbuf_loader_eat_header_write (loader, buf, count, error);
if (eaten <= 0)
- return FALSE;
+ {
+ gdk_pixbuf_loader_ensure_error (loader, error);
+ return FALSE;
+ }
count -= eaten;
buf += eaten;
@@ -461,19 +469,8 @@ gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
gboolean retval;
retval = priv->image_module->load_increment (priv->context, buf, count,
error);
- if (!retval && error && *error == NULL)
- {
- /* Fix up busted image loader */
- g_warning ("Bug! loader '%s' didn't set an error on failure",
- priv->image_module->module_name);
- g_set_error (error,
- GDK_PIXBUF_ERROR,
- GDK_PIXBUF_ERROR_FAILED,
- _("Internal error: Image loader module '%s'"
- " failed to begin loading an image, but didn't"
- " give a reason for the failure"),
- priv->image_module->module_name);
- }
+ if (!retval)
+ gdk_pixbuf_loader_ensure_error (loader, error);
return retval;
}
@@ -716,7 +713,10 @@ gdk_pixbuf_loader_close (GdkPixbufLoader *loader,
if (priv->image_module && priv->image_module->stop_load && priv->context)
{
if (!priv->image_module->stop_load (priv->context, error))
- retval = FALSE;
+ {
+ gdk_pixbuf_loader_ensure_error (loader, error);
+ retval = FALSE;
+ }
}
priv->closed = TRUE;