From: Sandro Santilli <strk@keybit.net>
Date: Sat, 17 Apr 2010 11:06:07 +0000 (+0000)
Subject: Plug a couple of memory leaks
X-Git-Tag: 2.0.0alpha1~3024
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea31804d470cbf45a80875e012910011c7a99eb3;p=postgis

Plug a couple of memory leaks

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

diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c
index 57a04dd3d..040b669dd 100644
--- a/postgis/lwgeom_geos.c
+++ b/postgis/lwgeom_geos.c
@@ -3576,7 +3576,12 @@ LWGEOM2GEOS(LWGEOM *lwgeom)
 		for (i=0; i<ngeoms; ++i)
 		{
 			GEOSGeometry* g = LWGEOM2GEOS(lwc->geoms[i]);
-			if ( ! g ) return NULL;
+			if ( ! g )
+			{
+				while (i) GEOSGeom_destroy(geoms[--i]);
+				free(geoms);
+				return NULL;
+			}
 			geoms[i] = g;
 		}
 		g = GEOSGeom_createCollection(geostype, geoms, ngeoms);