From ca2c51b684606d2096fb7d66dc7e051e03e83ff0 Mon Sep 17 00:00:00 2001
From: Luc Hermitte <luc.hermitte@c-s.fr>
Date: Tue, 19 Jun 2012 18:29:20 +0200
Subject: [PATCH] COMP: OTB-151/GeometriesProjectionFilter -- releasing
 OGRSpatialReference with old GDAL versions

---
 .../Filtering/GeometriesChangeSpatialReference.cxx   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Examples/Filtering/GeometriesChangeSpatialReference.cxx b/Examples/Filtering/GeometriesChangeSpatialReference.cxx
index 158bb63b21..b79fc20ec9 100644
--- a/Examples/Filtering/GeometriesChangeSpatialReference.cxx
+++ b/Examples/Filtering/GeometriesChangeSpatialReference.cxx
@@ -33,8 +33,16 @@ namespace internal
 {
 struct Deleters
 {
-  void operator()(OGRCoordinateTransformation *p){ OCTDestroyCoordinateTransformation(p); }
-  void operator()(OGRSpatialReference *p){ OGRSpatialReference::DestroySpatialReference(p); }
+  void operator()(OGRCoordinateTransformation *p) const { OCTDestroyCoordinateTransformation(p); }
+  void operator()(OGRSpatialReference *p) const
+    {
+#if GDAL_VERSION_NUM >= 1700
+    OGRSpatialReference::DestroySpatialReference(p);
+#else
+#warning the following resource release may crash, please update your version of GDAL
+    delete p; // note there is no garanty
+#endif
+    }
 };
 } // internal namespace
 
-- 
GitLab