Ticket #2238 (closed defect: wontfix)

Opened 5 years ago

Last modified 5 years ago

segfault with Clone() called on GeometryRef of Feature

Reported by: steko Owned by: hobu
Priority: normal Milestone:
Component: PythonBindings Version: 1.5.0
Severity: minor Keywords:
Cc:

Description

originalFile = ogr.Open('data.shp')
memory = ogr.GetDriverByName('Memory')
workingFile = memory.CopyDataSource(originalFile,'TemporaryDS')
workingLayer = workingFile[0]
self.workingLayer.ResetReading()

# create a copy of this geometry
total_geometry = self.workingLayer.GetFeature(1).GetGeometryRef().Clone()

The last line will result in a segfault, even though feature 1 exists and has a Geometry. This

total_geometry = self.workingLayer.GetFeature(1).GetGeometryRef()

works without any problem. This can probably be solved not using a oneliner.

Change History

Changed 5 years ago by hobu

  • status changed from new to closed
  • resolution set to wontfix

This is definitely a variable scoping issue. I would call it a bug, but it isn't going to be fixed any time soon. Please use more verbose method calls to ensure intermediate variables do not go out of scope.

Note: See TracTickets for help on using tickets.