[geos-devel] GEOS cross-heap problems

Frank Warmerdam warmerdam at pobox.com
Tue May 12 16:38:59 EDT 2009


Folks,

I had a serious problem reported by a client of mine. The issue turned out
to be that the OSGeo4W GEOS package was built with a different version of
visual studio than the OSGeo4W GDAL package.  The GDAL package calls:

     pabyBuf = GEOSGeomToWKB_buf( geosGeom, &nSize );
     ...
     free( pabyBuf );

The problem is that the buffer allocated by GEOS c-runtime is being freed
with the free() of the GDAL c-runtime resulting in heap corruption.

For things like geometry and coordinate sequences we have special
deallocators available as part of the GEOS C API.  However this is not
the case (as far as I know) for plain malloc()/free() type stuff.

So my questions are:

  1) Am I missing an existing GEOSFree() function?

  2) Shall I go ahead and add such a thing?

  3) If I do, are there objections to me incorporating it into the GEOS 3.0
     branch too?  This is what OSGeo4W depends on.

PS. I believe such a free function would also be appropriate to use for
the results of GEOSGeomType(), GEOSGeomToWKT(), and GEOSGeomtoHEX_buf().

PPS. I have to say, featuring the GEOS API docs so far down the main page
under "Other Information" seems cruel!

PPPS. Do we have C API docs?  Do we intend to?

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



More information about the geos-devel mailing list