[postgis-tickets] r17539 - lwgeom_transform_from_str: Avoid leaking resources under PROJ6+

Raul raul at rmr.ninja
Wed Jun 19 08:07:49 PDT 2019


Author: algunenano
Date: 2019-06-19 08:07:49 -0700 (Wed, 19 Jun 2019)
New Revision: 17539

Modified:
   trunk/NEWS
   trunk/liblwgeom/lwgeom_transform.c
Log:
lwgeom_transform_from_str: Avoid leaking resources under PROJ6+

Closes #4429


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2019-06-19 15:02:57 UTC (rev 17538)
+++ trunk/NEWS	2019-06-19 15:07:49 UTC (rev 17539)
@@ -23,6 +23,7 @@
   - #4388, AddRasterConstraints: Ignore NULLs when generating constraints (Raúl Marín)
   - #4327, Avoid pfree'ing the result of getenv (Raúl Marín)
   - #4406, Throw on invalid characters when decoding geohash (Raúl Marín)
+  - #4372, Avoid resource leaks with PROJ6 (Raúl Marín)
 
 PostGIS 3.0.0alpha1
 2019/05/26

Modified: trunk/liblwgeom/lwgeom_transform.c
===================================================================
--- trunk/liblwgeom/lwgeom_transform.c	2019-06-19 15:02:57 UTC (rev 17538)
+++ trunk/liblwgeom/lwgeom_transform.c	2019-06-19 15:07:49 UTC (rev 17539)
@@ -219,20 +219,26 @@
 	if (!pj)
 	{
 		PJ *pj_in = proj_create(NULL, instr);
-		PJ *pj_out = proj_create(NULL, outstr);
 		if (!pj_in)
 		{
 			lwerror("could not parse proj string '%s'", instr);
 		}
+		proj_destroy(pj_in);
+
+		PJ *pj_out = proj_create(NULL, outstr);
 		if (!pj_out)
 		{
-			proj_destroy(pj_in);
 			lwerror("could not parse proj string '%s'", outstr);
 		}
+		proj_destroy(pj_out);
+		lwerror("%s: Failed to transform", __func__);
 		return LW_FAILURE;
 	}
 
-	return lwgeom_transform(geom, pj);
+	int ret = lwgeom_transform(geom, pj);
+	proj_destroy(pj);
+
+	return ret;
 }
 
 int



More information about the postgis-tickets mailing list