]> granicus.if.org Git - postgis/commitdiff
lwgeom_transform_from_str: Avoid leaking resources under PROJ6+
authorRaúl Marín Rodríguez <rmrodriguez@carto.com>
Wed, 19 Jun 2019 15:07:49 +0000 (15:07 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Wed, 19 Jun 2019 15:07:49 +0000 (15:07 +0000)
Closes #4429

git-svn-id: http://svn.osgeo.org/postgis/trunk@17539 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/lwgeom_transform.c

diff --git a/NEWS b/NEWS
index 38911a1d9347edbe33e997c4f47d904807f7bf8c..7341e7fbf1c4d49793808770ab32724ea8d60d27 100644 (file)
--- 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
index a1844b18d6f26b4d8517519a0a9e3e405847ef15..af4b09453c716bbbe611bc91b871cca5e3544d14 100644 (file)
@@ -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