Ticket #1535 (closed defect: fixed)
OGR Interlis driver GetNextFeature() returns a pointer to a feature that it holds on to
| Reported by: | traianstanev | Owned by: | pka |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.4.2 |
| Component: | OGR_SF | Version: | 1.4.0 |
| Severity: | major | Keywords: | interlis |
| Cc: | warmerdam |
Description
GetNextFeature? is supposed to return a new feature that the caller will then destroy using OGRFeature::DestroyFeature?. In the Interlis 2 driver, GetNextFeature? returns a pointer to an OGRFeature that is part of a collection of features that the layer holds on to between subsequent reads. When the caller destroys the feature, the original feature is freed. If one then calls ResetReading? on the layer, it returns pointers to freed memory. The fix that worked for me is as follows:
OGRFeature *OGRILI2Layer::GetNextFeature?() {
if (listFeatureIt != listFeature.end())
return (*(listFeatureIt++))->Clone();
return NULL;
}
I added the call to Clone().
