[Gdal-dev] /MD on Windows, SDTS problem and fix

Ben Discoe ben at vterrain.org
Thu May 22 15:06:08 EDT 2003


Recently i've been hitting memory problems with OGR, so i wanted to switch
to using /MD to build GDAL with MSVC.  In fact, i notice that this change
was checked into nmake.opt recently as well - and it's a good move.

However, switching to /MD caused a bug to pop up with using OGR to read
certain SDTS files.  I have tracked the bug down, and found it has to do
with using realloc() on a string that is precisely the length of its buffer,
which can cause (depending on heap conditions) an unterminated string and
subsequent crash.

Here is the 1-line fix:

RCS file: /cvsroot/osrs/gdal/frmts/iso8211/ddffielddefn.cpp,v
diff -w -r1.9 ddffielddefn.cpp
456c456
<                 if( (int) (strlen(pszExpandedContents) + strlen(pszDest))
---
>                 if( (int) (strlen(pszExpandedContents) + strlen(pszDest) +
1)

-Ben




More information about the Gdal-dev mailing list