AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.10.14 07:58 "[Tiff] WIN32 _TIFFrealloc() bug?", by Ville Herva
2004.10.15 20:01 "[Tiff] WIN32 _TIFFrealloc() bug?", by Ville Herva
2004.10.15 20:09 "Re: [Tiff] WIN32 _TIFFrealloc() bug?", by Frank Warmerdam
2004.10.15 21:47 "Re: [Tiff] WIN32 _TIFFrealloc() bug?", by Ville Herva
2004.10.16 07:52 "Re: [Tiff] WIN32 _TIFFrealloc() bug?", by Andrey Kiselev
2004.10.17 16:47 "RE: [Tiff] WIN32 _TIFFrealloc() bug?", by Larry Grill
2004.10.17 17:26 "Re: [Tiff] WIN32 _TIFFrealloc() bug?", by Ville Herva

2004.10.15 20:09 "Re: [Tiff] WIN32 _TIFFrealloc() bug?", by Frank Warmerdam

Ville Herva wrote:
> Hi,
>
> When opening an image on WIN32, libtiff-3.6.1 does:
>
> GlobalSize(NULL)
> _TIFFrealloc(void * 0x00000000, long 4) line 237
> TIFFReadDirectory(tiff * 0x001b5ec8) line 112 + 25 bytes

> TIFFClientOpen(const char * 0x009d4934, const char * 0x009d4920, thandle_t__ * 0x00000000, long (thandle_t__ *, void *, long)* 0x00627caa+_tiffFileReadProc(thandle_t__ *, void *, long), long (thandle_t__ *, void*, long)* 0x00627cd1 _tiffFileWriteProc(thandle_t__ *, void *, long), unsigned long (thandle_t__ *, unsigned long, int)* ...) line 367 + 9 bytes

> iTIFFOpen(char * 0x009d4920) line 669 + 51 bytes

Ville,

In CVS the _TIFFRealloc implementation in tif_win32.c has been changed to the following as others have reported the same issue. I imagine this new implementation is in the latest libtiff 3.7.0 beta as well, which I would encourage you to try out. There are a number of known (and fixed) issues with the libtiff 3.6.1 and earlier releases.

tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
  void* pvTmp;

         tsize_t old;

         if(p == NULL)
                 return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));

         old = GlobalSize(p);

  if (old>=s)
    {
      if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
        CopyMemory(pvTmp, p, s);
        GlobalFree(p);
      }
    }
  else
    {
      if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
        CopyMemory(pvTmp, p, old);
        GlobalFree(p);
      }
    }
  return ((tdata_t)pvTmp);
}

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent