From d9600788218d28f87b61dff606c91a4b1f7861bc Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Fri, 22 Jun 2012 17:31:41 +0200
Subject: [PATCH] BUG: Ensure that SRS is not null before dereferencing

---
 Code/Common/otbPersistentImageToOGRLayerFilter.txx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Code/Common/otbPersistentImageToOGRLayerFilter.txx b/Code/Common/otbPersistentImageToOGRLayerFilter.txx
index 5769622900..5545492503 100644
--- a/Code/Common/otbPersistentImageToOGRLayerFilter.txx
+++ b/Code/Common/otbPersistentImageToOGRLayerFilter.txx
@@ -92,7 +92,7 @@ PersistentImageToOGRLayerFilter<TImage>
   // the spatial reference of the input image
   OGRSpatialReference oSRS(this->GetInput()->GetProjectionRef().c_str());
   
-  if(!oSRS.IsSame(m_OGRLayer.GetSpatialRef()))
+  if(m_OGRLayer.GetSpatialRef() && !oSRS.IsSame(m_OGRLayer.GetSpatialRef()))
      {
      itkExceptionMacro(<<"Spatial reference of input image and target layer do not match!");
      }
@@ -119,7 +119,7 @@ PersistentImageToOGRLayerFilter<TImage>
 
 
   // Check spatial reference matches
-  if(!srcLayer.GetSpatialRef()->IsSame(m_OGRLayer.GetSpatialRef()))
+  if(srcLayer.GetSpatialRef() && m_OGRLayer.GetSpatialRef() && !srcLayer.GetSpatialRef()->IsSame(m_OGRLayer.GetSpatialRef()))
      {
      itkExceptionMacro(<<"Spatial reference of internal and target layers do not match!");
      }
-- 
GitLab