[gdk-pixbuf] PNM: Generate an error if no pixbuf could be produced



commit 67615b575a683a7e28387dda65ae8976ac999290
Author: Felix Riemann <friemann gnome org>
Date:   Sun Aug 2 20:42:32 2020 +0200

    PNM: Generate an error if no pixbuf could be produced
    
    This is expected by the loader API which trips over an assertion otherwise.
    Partially loaded images still work while images that are too truncated
    fail gracefully.
    
    Fixes #111.

 gdk-pixbuf/io-pnm.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c
index 91e7dca677..856501ae59 100644
--- a/gdk-pixbuf/io-pnm.c
+++ b/gdk-pixbuf/io-pnm.c
@@ -873,6 +873,12 @@ gdk_pixbuf__pnm_image_stop_load (gpointer data,
        
        if (context->pixbuf)
                g_object_unref (context->pixbuf);
+       else {
+               g_set_error_literal (error, GDK_PIXBUF_ERROR,
+                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                    _("Premature end-of-file encountered"));
+               retval = FALSE;
+       }
 
 #if 0
        /* We should ignore trailing newlines and we can't


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