2012.05.18 13:23 "[Tiff] TIFFGetField: count should be uint32_t (Bug in documentation)", by Sandro Mani
Hello,
according to [1], when querying multi-valued fields with TiffGetField, count should be of a 16-bit unsigned integer. However, in various places in the source libtiff source code, a 32-bit unsigned integer is used. Indeed, a nasty bug I encountered was caused by count being 16 bits wide:
uint16_t count;
uint32_t width;
void* data;
std::cout<<&width<<" "<<&count<<std::endl;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width);
std::cout<<width<<std::endl;
TIFFGetField(tif, TIFFTAG_MODELTIEPOINT, &count, &data);
std::cout<<width<<std::endl;
Output:
0x7fffa4d38a68 0x7fffa4d38a66
7721
0
=> Count overflowed into width
If my analysis is correct, I guess the documentation should be fixed.
Thanks,
Sandro
[1] http://www.remotesensing.org/libtiff/man/TIFFGetField.3tiff.html