Ticket #2151 (closed defect: fixed)
Small bug in libTIFF on Windows CE
| Reported by: | fbausch | Owned by: | mloskot |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | WinCE Port | Version: | svn-trunk |
| Severity: | normal | Keywords: | |
| Cc: | warmerdam |
Description
in GDAL, frmts/gtiff/libtiff/tif_dirinfo.c - in the tagCompare routine, which tests inputs a and b for field_tag and field_type match. in the current form, it tests the a parameter (the ta tag) for a wildcard setting (TIFF_ANY), which would allow a simple field_tag match to return success.
but when tagCompare is called in this chain: TIFFFindField - bsearch - tagCompare, it is the b parameter which is specified with the wildcard field (in TIFFFindField); this wildcard is pointless, since only the a parameter is tested for the wildcard setting.
Other call sequences that lead to tagCompare may be different, but in the sequence through TIFFFindField, it is the b parameter which can hold the wildcard type specification, and not the a parameter. the change below fixes the wildcarding operation - other solutions could be to reverse the field parameter order in the call to tagCompare in bsearch (or in TIFFFindField's call to bsearch)
static int tagCompare(const void* a, const void* b) {
const TIFFField* ta = *(const TIFFField**) a; const TIFFField* tb = *(const TIFFField**) b; /* NB: be careful of return values for 16-bit platforms */ if (ta->field_tag != tb->field_tag)
return (int)ta->field_tag - (int)tb->field_tag;
else
// return (ta->field_type == TIFF_ANY) ? // 0 : ((int)tb->field_type - (int)ta->field_type);
return (tb->field_type == TIFF_ANY) ? // changed return 0 : ((int)tb->field_type - (int)ta->field_type);
}
