diff --git a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx index 2973a7a8a3a2e251cdef0ffcf55f034eb6b217aa..502438a0d2a4ebb6bc1b85ce59e8e419fb16206a 100644 --- a/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx +++ b/Modules/Learning/Sampling/include/otbPersistentSamplingFilterBase.txx @@ -265,6 +265,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } this->m_InMemoryOutputs.push_back(tmpContainer); } + + if (oSRS) + { + oSRS->Release(); + } } template <class TInputImage, class TMaskImage> @@ -734,7 +739,7 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> } const unsigned int nbFeatThread = std::ceil(inLayer.GetFeatureCount(true) / (float) numberOfThreads); - assert(nbFeatThread > 0); + //assert(nbFeatThread > 0); OGRFeatureDefn &layerDefn = inLayer.GetLayerDefn(); ogr::Layer::const_iterator featIt = inLayer.begin(); @@ -807,6 +812,11 @@ PersistentSamplingFilterBase<TInputImage,TMaskImage> OGRFieldDefn fieldDefn(layerDefn.GetFieldDefn(k)); outLayer.CreateField(fieldDefn); } + + if (oSRS) + { + oSRS->Release(); + } } // Add new fields diff --git a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx index 138032ea734aad7266bdfb020d54d547be05a9b3..414a7730276e95d4f41392d04c458d9f3af80035 100644 --- a/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx +++ b/Modules/Learning/Sampling/test/otbImageSampleExtractorFilterTest.cxx @@ -129,6 +129,7 @@ int otbImageSampleExtractorFilterUpdate(int argc, char* argv[]) output->CreateLayer( inLayer.GetName(), oSRS, inLayer.GetLayerDefn().GetGeomType()); + oSRS->Release(); otb::ogr::Layer dstLayer = output->GetLayer(0); OGRFieldDefn labelField(classFieldName.c_str(),OFTString); dstLayer.CreateField(labelField, true);