2013.04.10 22:40 "[Tiff] Getting a crash after calling TIFFReadRGBAImageOriented()", by Bruce A. Mallett
The man page for TIFFReadRGBAImage()/TIFFReadRGBAImageOriented() indicates that if I pass in a raster less high than the source image this function will crop accordingly. If I want only the very last scanline of a 1024x800 image then it sounds like I can do something like this:
- get my TIFF handle in hTiff
- allocate a raster buffer (an array of 800 32 bit values) to rasterBuf
- call TIFFReadRGBAImageOriented( hTiff, 800, 1, rasterBuf,
This crashes because when TIFFReadRGBAImageOriented() calls TIFFRGBAImageGet() it does so as follows:
ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth,
Substituting rheight=1, img.height=800, rwidth=1024 this becomes:
ok = TIFFRGBAImageGet(&img, raster+(1-800)*1024,
ok = TIFFRGBAImageGet(&img, raster - 818176,
Given that "raster" is a uint32 *" TIFFRGBAImageGet() receives an address that is 4*818176 before the start of raster. Eventually this bubbles down to gtStripContig() and then to putRGBUAcontig8bittile() which segfaults trying to put a uint32 value to that address.
I'm curious if I'm reading the man page wrong or I'm using this wrong or if the code is wrong.
P.S. While stepping in gdb I found this amusing bit of code in gtStripContig():
toskew = -(int32)(w - w);
One too many edits?