2006.10.26 15:21 "[Tiff] TIFFReadPrivateDirectory function is not working for SUBIFD", by Anurag Singh

2006.10.27 19:11 "Re: [Tiff] TIFFReadPrivateDirectory function is not working for SUBIFD", by Sebastian Boehmer

Anurag Singh schrieb:

one another important issue comes, i have made one change in __TIFFReadCustomDirectoryPart for our own purpose to read subifd, it's very true that at the time of reading any SubIFD, there's no one tag is registered, because we are passing these parameters tif->tif_nPrivateFields, tif->tif_privateFieldInfo, which are initially NULL.

ok that's no prob. In a first call of __TIFFMergeFieldInfo(&tif->tif_nPrivateFields,&tif->tif_privateFieldInfo,n,info,1)

is tif_nPrivateFields=0 and tif_privateFieldInfo=NULL, but n is not zero and info is not NULL.

If info=NULL and n not zero there was a wrong call of the function TIFFMergePrivateFieldInfo.

    n should be the size of the new to merged info.

So each n very time tag goes to merge by using TIFFMergePrivateFieldInfo() and in turn this function make call __TIFFMergeFieldInfo(&tif->tif_nPrivateFields,&tif->tif_privateFieldInfo,n,info,1), after merging 2-3 times, i got HEAP error in this funtion, and reason of it, mergedIndices is currupted.

i want explain it, we are merging one tag each n every time, so here n=1 and info have one tag only.

You mean you call the TIFFMergedPrivateFieldInfo n times with the same tag? The sorted array tif->tif_privateFieldInfo contains only tags with unique tag numbers!

For this reason we check in the loop you quoted below if info contains a new tag.

I think problem is here. this is the code of function __TIFFMergeFieldInfo

Sorry I don't realy understand your problem. Perhapse could you explain it for me in a private e-mail.

--
greets

if ( support ) {

> mergedIndices = _TIFFmalloc(n*
>
> sizeof(int));

}

if (*nfields > 0) {
if ( support ) {

/*

* Merge only not already existing tags. Asume unsorted TIFFFieldInfo array.

*/

for (fi=0; fi < *nfields; ++fi) {

     for (i =0; i < n; ++i)

        if (info_new[i].field_tag == (*info)[fi]->field_tag)

       break;

    if ( i >= n ) { // entry not found

    mergedIndices[nn] = i; // remember index

   ++nn;

}

}

if ( nn == 0 ) goto end; // no new entries;

n = nn;

}

we are allocationg memory to mergedIndices of size n, mean in the SubIFD's case 1 and adding more than value, here is some logical error for tha case when only one tag is merged in a group.

Please have a look on this problem.

> ------------------------------------------------------------------------
>
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/