[gimp] plug-ins: libtiff warnings can cause a crash on Windows.



commit 97739af6431a51244a615207226aee610fa2138a
Author: Jacob Boerema <jgboerema gmail com>
Date:   Tue Mar 2 14:51:31 2021 -0500

    plug-ins: libtiff warnings can cause a crash on Windows.
    
    Certain broken tiff fax images can cause a huge amount of warnings
    which on Windows eventually causes GIMP to run out of resources
    and then crash.
    
    Since the avarage user won't have much use for these warnings
    let's just only send them to stderr.

 plug-ins/file-tiff/file-tiff-io.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/plug-ins/file-tiff/file-tiff-io.c b/plug-ins/file-tiff/file-tiff-io.c
index 6c0a3040b4..ca1a434dcb 100644
--- a/plug-ins/file-tiff/file-tiff-io.c
+++ b/plug-ins/file-tiff/file-tiff-io.c
@@ -210,6 +210,26 @@ tiff_io_warning (const gchar *module,
       /* We will process this issue in our code. Just report to stderr. */
       g_printerr ("%s: [%s] %s\n", G_STRFUNC, module, fmt);
 
+      return;
+    }
+  else if (! strcmp (module, "Fax4Decode") ||
+           g_str_has_prefix (module, "Fax3Decode"))
+    {
+      /* Certain corrupt TIFF Fax images can produce a large amount of
+       * warnings which can cause GIMP to run out of GDI resources on
+       * Windows and eventually crash.
+       * The real problem seems to be that the amount of error console
+       * messages does not have a limit.
+       * See e.g. the first page of m1-8110934bb3b18d0e87ccc1ddfc5f0107.tif
+       * from imagetestsuite. LibTiff does not return -1 from
+       * ReadScanline, presumably because for fax images it's not
+       * unreasonable to expect certain lines to fail.
+       * Let's just only report to stderr in this case. */
+      gchar *msg = g_strdup_vprintf (fmt, ap);
+
+      g_printerr ("LibTiff warning: [%s] %s\n", module, msg);
+      g_free (msg);
+
       return;
     }
 


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