1999.11.25 07:18 "Problem with libtiff CCITT Fax 4 Decoder", by Kristian Sandven

Hi all!

I have successfully compiled the vc makefile for windows NT (I'm running NT 4 (SP5), VC++ 6.0 (SP3), libtiff v3.5.2 ) and have started to explore the features of libtiff. I have created a simple test app that can read and write tiff images. However I soon ran into some trouble with the CCITT FAX 4 decoder. Writing files in the CCITT FAX 4 format works just fine, but reading files in this format does not work. There seems to be some memory corruption problem(s).

TIFF *tif = TIFFOpen("somefile.tif, "r"); // somefile.tif is CCITT Group 4 encoded
// read strips with TIFFReadEncodedStrip(...) <==Problem???
TiFFClose(tif); <== Crash!!!

When calling TIFFClose the app dies and the debugger outputs the following messages

User breakpoint called from code at 0x77F7629C
HEAP[test_tiff.exe]: Heap block at 1361d8 modified at 1385e0 past requested size of 2400
HEAP[test_tiff.exe]: Invalid Address specified to RtlFreeHeap( 130000, 1361e0 )
HEAP[test_tiff.exe]: Heap block at 1361d8 modified at 1385e0 past requested size of 2400
The thread 0x109 has exited with code 0 (0x0).
The program 'E:\Arbeid\MyProjects\test_tiff\Debug\test_tiff.exe' has exited with code 0 (0x0).

The output above indicates that the CCITT FAX 4 decoder (or some other part of libtiff) write outside the allocated memory area and that it tries to free a area that is not allocated by libtiff. Everything is pointing towards an error in the CCITT Fax 4 decoder. Additionally when trying to free up memory allocated with GlobalAlloc before calling TIFFClose i get a DAMAGED MEMORY warning from the debugger.
I don't get this warning when using any of the other codecs.

Does anyone know a solution to the problem(s) above, is there an error in the CCITT FAX 4 Decoder and if not what could cause the problems described above.

Thank you very much for your help,
I look forward hearing from you,
with best regards,

Kristian