After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 517233 - Calling gdk_pixbuf_loader_close causes "GError set over the top of a previous GError" warning
Calling gdk_pixbuf_loader_close causes "GError set over the top of a previous...
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-02-18 15:01 UTC by Andrey Tsyvarev
Modified: 2010-07-10 04:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ensure that an error wasn't already set before trying to set the second one (538 bytes, patch)
2008-03-11 21:49 UTC, Claudio Saavedra
none Details | Review

Description Andrey Tsyvarev 2008-02-18 15:01:00 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
Comment 1 Claudio Saavedra 2008-03-11 21:37:12 UTC
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;
       }
   }
Comment 2 Claudio Saavedra 2008-03-11 21:49:23 UTC
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.
Comment 3 Andrey Tsyvarev 2008-03-12 11:07:25 UTC
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)".
Comment 4 Matthias Clasen 2008-09-07 05:01:57 UTC
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