diff --git a/inst/include/gdallibrary/gdallibrary.h b/inst/include/gdallibrary/gdallibrary.h index 319d1f0..9b285c9 100644 --- a/inst/include/gdallibrary/gdallibrary.h +++ b/inst/include/gdallibrary/gdallibrary.h @@ -90,8 +90,11 @@ inline R_xlen_t force_layer_feature_count(OGRLayer *poLayer) { if (out == -1) { out = 0; poLayer->ResetReading(); - while(poLayer->GetNextFeature() != NULL) { - out++; + OGRFeature *poFeature; + while( (poFeature = poLayer->GetNextFeature()) != NULL ) + { + out++; + OGRFeature::DestroyFeature( poFeature ); } poLayer->ResetReading(); }