[gdk-pixbuf/issue-132: 11/12] pixdata: Bail out if the error is set



commit 1f390c595014cf3fb77113544a21acf0fdcf5c30
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Apr 1 18:07:44 2020 +0100

    pixdata: Bail out if the error is set
    
    We might still get a GdkPixbuf even if the GError is set, which leads to
    us reusing the GError instance later on.

 gdk-pixbuf/gdk-pixbuf-pixdata.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-pixdata.c b/gdk-pixbuf/gdk-pixbuf-pixdata.c
index 3ce5a2b40..012bd2f3e 100644
--- a/gdk-pixbuf/gdk-pixbuf-pixdata.c
+++ b/gdk-pixbuf/gdk-pixbuf-pixdata.c
@@ -75,7 +75,7 @@ main (int   argc,
 #endif
 
   pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
-  if (!pixbuf)
+  if (error != NULL)
     {
       g_printerr ("failed to load \"%s\": %s\n",
                  argv[1],
@@ -88,6 +88,11 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   free_me = gdk_pixdata_from_pixbuf (&pixdata, pixbuf, use_rle);
   data = gdk_pixdata_serialize (&pixdata, &data_len);
 G_GNUC_END_IGNORE_DEPRECATIONS
+  if (data == NULL)
+    {
+      g_printerr ("failed to serialize \"%s\"", argv[1]);
+      return 1;
+    }
 
   if (!g_file_set_contents (outfilename, (char *)data, data_len, &error))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]