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.

(cherry picked from commit 97739af643)
This commit is contained in:
Jacob Boerema
2021-03-02 14:51:31 -05:00
parent b5504159ed
commit 753c596404

View File

@ -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;
}