diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx index a14fb04645d06eff264902e68f18fb402854e099..872823276c87bf9e8c49de03468d75deedd98e05 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx @@ -232,7 +232,8 @@ OGRSpatialReference const* otb::ogr::Layer::GetSpatialRef() const std::string otb::ogr::Layer::GetProjectionRef() const { char * wkt; - + std::string stringWkt = ""; + assert(m_Layer && "OGRLayer not initialized"); OGRSpatialReference * srs = m_Layer->GetSpatialRef(); @@ -246,14 +247,10 @@ std::string otb::ogr::Layer::GetProjectionRef() const itkGenericExceptionMacro(<< "Cannot convert spatial reference to wkt string for layer <" <<m_Layer->GetName()<<">: " << CPLGetLastErrorMsg()); } - } - - std::string stringWkt(wkt); + stringWkt = wkt; - // According to documentation, argument of exportToWkt() should be - // freed - if(srs) - { + // According to documentation, argument of exportToWkt() should be + // freed CPLFree(wkt); }