Quantcast
Channel: Question and Answer » gdal
Viewing all articles
Browse latest Browse all 397

OGRFeature::DestroyFeature fails

$
0
0

I am using OGR to read features from a shape file; when the feature is destroyed I am getting an error 0xC0000005: Access violation reading location 0xffffffffffffffff.

This secton of the code looks pointless but is a simplification of a larger section showing where the error is occuring. I have removed lines of code that could interfere with the objects and I am still getting the same error message.

OGRDataSource *hDS;
OGRSFDriver   *Driver;
OGRFeature    *pFeat;

hDS = OGRSFDriverRegistrar::Open(BasePath,FALSE,&Driver);
OGRLayer *Layer = hDS->GetLayerByName(ThisLayerName);
Layer->ResetReading();

while ((pFeat = Layer->GetNextFeature()) != NULL)
{
    // I did intend to do something here
    OGRFeature::DestroyFeature(pFeat); // error occurs here
}
OGRDataSource::DestroyDataSource(hDS);

I am using OGR2OGR source as a reference on how to read an OGR datasource. I can see in the reference that each feature returned is destroyed before grabbing a new one until the last feature and the datasource is destroyed thereafter.

I am using GDAL version 1.10 64bit on Windows 7 64bit; I have tried previous versions 1.9.2 and 1.8 and they all return the same error. I am using Visual C++ if that makes any difference.


Viewing all articles
Browse latest Browse all 397

Trending Articles