From: Sandro Santilli Date: Mon, 15 Feb 2010 20:40:32 +0000 (+0000) Subject: Plug memory leak on GEOS geom construction failure [RT-SIGTA] X-Git-Tag: 2.0.0alpha1~3247 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9bacd1318a9e337f9a55a20a933231de9ecd0da;p=postgis Plug memory leak on GEOS geom construction failure [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@5243 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index ae9323649..1c5da1591 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -3532,7 +3532,12 @@ LWGEOM2GEOS(LWGEOM *lwgeom) { sq = ptarray_to_GEOSCoordSeq(lwpoly->rings[i]); geoms[i-1] = GEOSGeom_createLinearRing(sq); - if ( ! geoms[i-1] ) return NULL; + if ( ! geoms[i-1] ) { + --i; + while (i) GEOSGeom_destroy(geoms[i-1]); + free(geoms); + return NULL; + } /*lwerror("LWGEOM2GEOS: exception during polygon hole conversion"); */ } g = GEOSGeom_createPolygon(shell, geoms, ngeoms);