]> granicus.if.org Git - postgis/commitdiff
Fix memory leak in lwgeom_offsetcurve
authorRaúl Marín Rodríguez <rmrodriguez@carto.com>
Fri, 7 Sep 2018 10:57:23 +0000 (10:57 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Fri, 7 Sep 2018 10:57:23 +0000 (10:57 +0000)
References #4172

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

NEWS
liblwgeom/lwgeom_geos.c

diff --git a/NEWS b/NEWS
index 50e43e1b8862243d908465c443f9b9bdc9962272..f45bac9238d7021d89a17198055fd55ce0d20b6b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ New since PostGIS 2.5.0rc1
   - #4162, ST_DWithin documentation examples for storing geometry and
     radius in table (Darafei Praliaskouski, github user Boscop).
   - #4163, MVT: Fix resource leak when the first geometry is NULL (Raúl Marín)
+  - #4172, Fix memory leak in lwgeom_offsetcurve (Raúl Marín)
 
 PostGIS 2.5.0rc1
 2018/08/19
index ece4c2439d0268ee402cbea74903e7d6acb0a799..96dc8cea85706a2ab38fb2406eb61f2de8ef8fb5 100644 (file)
@@ -1389,13 +1389,15 @@ lwgeom_offsetcurve(const LWGEOM* geom, double size, int quadsegs, int joinStyle,
                }
 
                if (result)
+               {
+                       if (noded) lwgeom_free(noded);
                        return result;
+               }
                else if (!noded)
                {
                        noded = lwgeom_node(geom);
                        if (!noded)
                        {
-                               lwfree(noded);
                                lwerror("lwgeom_offsetcurve: cannot node input");
                                return NULL;
                        }
@@ -1403,10 +1405,12 @@ lwgeom_offsetcurve(const LWGEOM* geom, double size, int quadsegs, int joinStyle,
                }
                else
                {
+                       lwgeom_free(noded);
                        lwerror("lwgeom_offsetcurve: noded geometry cannot be offset");
                        return NULL;
                }
        }
+
        return result;
 }