From 65467c1ce09ae53214ace3e05d2b256c7af75b8d Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@orfeo-toolbox.org> Date: Wed, 20 Jun 2012 16:28:23 +0200 Subject: [PATCH] BUG: Fixing output string when no output projection is found --- .../OGRAdapters/otbOGRLayerWrapper.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRLayerWrapper.cxx index a14fb04645..872823276c 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); } -- GitLab