TIFFClose() should return a status value
Summary
It's currently impossible to check if closing the image succeeded or failed and (silently) created an unreadable corrupted image.
Version
All of them.
Steps to reproduce
This is not obvious, but doesn't really matter much: whichever is the cause of failure, currently the function can't return it because it's void
. In my particular case, it turned out that the code was doing
int xres = ...;
TIFFSetField(tif, TIFFTAG_XRESOLUTION, xres);
which somehow "worked" before even though the resolution tag needs a double. After a compiler upgrade, it stopped working because the bit patterns in memory now happened to represent a NaN and TIFFWriteDirectoryTagRational()
failed, resulting in TIFFWriteDirectorySec()
, TIFFWriteDirectory()
, TIFFRewriteDirectory()
, TIFFFlush()
failing in turn -- but in TIFFCleanup()
the error code of the latter is just ignored and lost and doesn't get to TIFFClose()
neither.
Note that I ran into this problem due to a bug in my own code, but it can also happen for any IO error. I probably could set a flag in the error handler and check it after calling TIFFClose()
, but this is a much more roundabout way than just checking the return value of that function. And it should be pretty simple to add a return value to it and it should be mostly backwards-compatible too and in the worst case some new TIFFCloseExt()
returning int
could be added and TIFFClose()
kept unchanged.
Platform
This is a platform-independent issue.