GNOME Bugzilla – Bug 517233
Calling gdk_pixbuf_loader_close causes "GError set over the top of a previous GError" warning
Last modified: 2010-07-10 04:04:46 UTC
Glib-WARNING appears when one tries to close a corrupted jpeg file. It states that the existing GError is overwritten by the new one: (process:919): GLib-WARNING **: GError set over the top of a previous GError or uninitialized memory. This indicates a bug in someone's code. You must ensure an error is NULL before it's set. The overwriting error message was: Error interpreting JPEG image file (Improper call to JPEG library in state 202) New content of the GError is: Error interpreting JPEG image file (Quantization table 0x00 was not defined). The detailed bug description can be found at: http://linuxtesting.org/results/report?num=S0624
The problem is in this bunch of code in gdk-pixbuf-loader.c, in which it's possible that two errors are propagated: if (priv->image_module == NULL) { GError *tmp = NULL; gdk_pixbuf_loader_load_module (loader, NULL, &tmp); if (tmp != NULL) { g_propagate_error (error, tmp); <-- FIRST ERROR IS PROPAGATED retval = FALSE; } } if (priv->image_module && priv->image_module->stop_load && priv->context) { GError *tmp = NULL; if (!priv->image_module->stop_load (priv->context, &tmp) || tmp) { /* don't call gdk_pixbuf_loader_ensure_error() * here, since we might not get an error in the * gdk_pixbuf_get_file_info() case */ if (tmp) g_propagate_error (error, tmp); <-- SECOND ERROR IS PROPAGATED retval = FALSE; } }
Created attachment 107095 [details] [review] ensure that an error wasn't already set before trying to set the second one This is a potential fix. Not sure if it's what people would expect.
Patch is probably not correct because tmp may not be cleared in some cases(if error == NULL or error has already been set). Else statement with code "g_error_free(tmp);" would be appropriate. Also, call of stop_load() after unsuccessfull call of load_increment() inside gdk_pixbuf_loader_load_module() seems suspicious: jpeg loader sets the second error to "Error interpreting JPEG image file (Improper call to JPEG library in state 202)".
2008-09-06 Matthias Clasen <mclasen@redhat.com> Bug 517233 – Calling gdk_pixbuf_loader_close causes "GError set over the top of a previous GError" warning * gdk-pixbuf-loader.c (gdk_pixbuf_loader_close): Don't overwrite errors. Reported by Andrey Tsyvarev