[Gdal-dev] OGR geometry transform memory issue

Frank Warmerdam warmerdam at pobox.com
Mon Nov 10 09:45:57 EST 2003


Brian Marchand wrote:
> Hello,
> 
>  
> 
> I found a crash in the OGR code due to freeing up the target 
> OGRSpatialReference object that is created by the 
> OGRCoordinateTransformation class when calling 
> OGRCreateCoordinateTransformation. The crash occurred when the geometry 
> transform method assigned the “target” OGRSpatialReference object that 
> was created by the transformation object. When I destroyed the 
> transformation object the OGRProj4CT destructor destroyed the 
> OGRSpatialReference and the geometry was then pointing to deleted 
> memory. The next time the geometry’s SRS object was used I would get a 
> crash.
> 
>  
> 
> It seems like the problem could be fixed two ways. Either the geometry 
> clones the OGRSpatialReference object instead of assigning it, or the 
> OGRCoordinateTransformation object looks at the reference count of the 
> target OGRSpatialReference object before deleting it.

Brian,

The correct approach would be to decrement and check the reference count
before destroying.  Cloning the coordinate system would be very expensive.
I will implement this in CVS and add a test to the testsuite.

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 Gdal-dev mailing list