From 1ba4bc209a772cf5360b432be9b501f04399c1cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ra=C3=BAl=20Mar=C3=ADn=20Rodr=C3=ADguez?= Date: Fri, 7 Sep 2018 10:57:23 +0000 Subject: [PATCH] Fix memory leak in lwgeom_offsetcurve References #4172 git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@16721 b70326c6-7e19-0410-871a-916f4a2858ee --- NEWS | 1 + liblwgeom/lwgeom_geos.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 50e43e1b8..f45bac923 100644 --- 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 diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c index ece4c2439..96dc8cea8 100644 --- a/liblwgeom/lwgeom_geos.c +++ b/liblwgeom/lwgeom_geos.c @@ -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; } -- 2.50.0