From 614135da5ba8c2b3dbb0aad6aaa9bb2159836368 Mon Sep 17 00:00:00 2001 From: BrianDelalex Date: Mon, 20 Nov 2023 08:23:26 +0100 Subject: [PATCH] Improve error checking when saving images in TIFF format Use TIFFFlush() in wxTIFFHandler::SaveFile() in order to check for success when saving TIFF images, as TIFFClose() doesn't have any error code to do it. Closes #23214. Closes #24072. --- src/common/imagtiff.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index 12d8d35e5f..fca23f48c6 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -859,6 +859,20 @@ bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo ptr += imageWidth * 3; } + if (!TIFFFlush(tif)) + { + if (verbose) + { + wxLogError( _("TIFF: Error flushing data.") ); + } + + TIFFClose(tif); + if (buf) + _TIFFfree(buf); + + return false; + } + (void) TIFFClose(tif); if (buf)