From: Raúl Marín Rodríguez Date: Wed, 19 Jun 2019 15:07:49 +0000 (+0000) Subject: lwgeom_transform_from_str: Avoid leaking resources under PROJ6+ X-Git-Tag: 3.0.0alpha3~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70db109b392c20c8d2572f3dd21b52a86e86f721;p=postgis lwgeom_transform_from_str: Avoid leaking resources under PROJ6+ Closes #4429 git-svn-id: http://svn.osgeo.org/postgis/trunk@17539 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 38911a1d9..7341e7fbf 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ Additional features enabled if you are running Proj6+ and PostgreSQL 12 - #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 diff --git a/liblwgeom/lwgeom_transform.c b/liblwgeom/lwgeom_transform.c index a1844b18d..af4b09453 100644 --- a/liblwgeom/lwgeom_transform.c +++ b/liblwgeom/lwgeom_transform.c @@ -219,20 +219,26 @@ lwgeom_transform_from_str(LWGEOM *geom, const char* instr, const char* outstr) 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