[gdal-dev] Possible bug in OGRSpatialReference:: importFromWkt()

Martin Chapman chapmanm at pixia.com
Thu Jan 12 21:30:22 EST 2012


Frank,

 

I think there is a bug in OGRSpatialReference::importFromWkt().  I did the
following: 

 

char* wkt = NULL;

sourceSRS.exportToWkt(&wkt);

targetSRS.importFromWkt(&wkt);

CPLFree(wkt);

 

It blows up on the CPLFree().  Why you might ask.  Because it looks like
the importFromWkt() increments the pointer as it's parsing it so by the
time it returns the pointer you passed in no longer points to the
beginning of the array of char* pointers. Instead, it points to the end of
the memory block.  Shouldn't you be assigning a temp pointer to the start
of the array before you start parsing it?  If you made it a const char**
parameter this wouldn't happen.  

 

Am I correct or did I use the functions incorrectly?

 

Best regards,

Martin

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120112/4d8aa4a4/attachment.html


More information about the gdal-dev mailing list