[GRASS-SVN] r71613 - grass/trunk/lib/proj

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 30 13:45:14 PDT 2017


Author: mmetz
Date: 2017-10-30 13:45:14 -0700 (Mon, 30 Oct 2017)
New Revision: 71613

Modified:
   grass/trunk/lib/proj/convert.c
Log:
projlib: fix segfault

Modified: grass/trunk/lib/proj/convert.c
===================================================================
--- grass/trunk/lib/proj/convert.c	2017-10-30 20:31:26 UTC (rev 71612)
+++ grass/trunk/lib/proj/convert.c	2017-10-30 20:45:14 UTC (rev 71613)
@@ -379,7 +379,7 @@
  *                    been defined
  */
 int GPJ_osr_to_grass(struct Cell_head *cellhd, struct Key_Value **projinfo,
-		     struct Key_Value **projunits, OGRSpatialReferenceH hSRS,
+		     struct Key_Value **projunits, OGRSpatialReferenceH hSRS1,
 		     int datumtrans)
 {
     struct Key_Value *temp_projinfo;
@@ -389,10 +389,13 @@
     char *datum = NULL;
     struct gpj_datum dstruct;
     const char *ograttr;
+    OGRSpatialReferenceH hSRS;
 
     *projinfo = NULL;
     *projunits = NULL;
 
+    hSRS = hSRS1;
+
     if (hSRS == NULL)
 	goto default_to_xy;
 
@@ -453,7 +456,6 @@
 			G_set_key_value("name", pszProj, *projinfo);
 		}
 
-		OSRDestroySpatialReference(hSRS);
 		hSRS = OSRNewSpatialReference(NULL);
 		if (OSRImportFromProj4(hSRS, proj4ext) != OGRERR_NONE) {
 		    G_fatal_error(_("Can't parse PROJ.4-style parameter string"));
@@ -830,6 +832,9 @@
 
     }
 
+    if (hSRS != hSRS1)
+	OSRDestroySpatialReference(hSRS);
+
     return 2;
 
     /* -------------------------------------------------------------------- */
@@ -846,6 +851,9 @@
     *projinfo = NULL;
     *projunits = NULL;
 
+    if (hSRS != hSRS1)
+	OSRDestroySpatialReference(hSRS);
+
     return 1;
 }
 #endif



More information about the grass-commit mailing list