[gdk-pixbuf] io-jpeg: Fix a potential infinite loop when failing to write out



commit 5916326b0427d8df50c5e1b0a2cc592de017935f
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Dec 12 23:03:22 2016 +0000

    io-jpeg: Fix a potential infinite loop when failing to write out
    
    If libjpeg fails to write out a scan line, this loop would never have
    terminated (as next_scanline would never be incremented). Fix that by
    checking for the return value from jpeg_write_scanlines().
    
    Coverity CID 1388533
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776026

 gdk-pixbuf/io-jpeg.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
index 81489c3..3b0a162 100644
--- a/gdk-pixbuf/io-jpeg.c
+++ b/gdk-pixbuf/io-jpeg.c
@@ -1513,7 +1513,12 @@ real_save_jpeg (GdkPixbuf          *pixbuf,
 
                /* write scanline */
                jbuf = (JSAMPROW *)(&buf);
-               jpeg_write_scanlines (&cinfo, jbuf, 1);
+               if (jpeg_write_scanlines (&cinfo, jbuf, 1) == 0) {
+                      jpeg_destroy_compress (&cinfo);
+                      retval = FALSE;
+                      goto cleanup;
+               }
+
                i++;
                y++;
 


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