From: Sandro Santilli Date: Wed, 6 Jul 2011 14:45:22 +0000 (+0000) Subject: Have lwcollection_extract clone (shallow) the extracted components. Safely lwgeom_fre... X-Git-Tag: 2.0.0alpha1~1232 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d0852e0b0c36efccfe2aa203add58edf6dbb145;p=postgis Have lwcollection_extract clone (shallow) the extracted components. Safely lwgeom_free the return from lwcollection_extract in testcase. git-svn-id: http://svn.osgeo.org/postgis/trunk@7610 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_libgeom.c b/liblwgeom/cunit/cu_libgeom.c index da38c5b6e..2b0f35809 100644 --- a/liblwgeom/cunit/cu_libgeom.c +++ b/liblwgeom/cunit/cu_libgeom.c @@ -328,7 +328,7 @@ static void test_lwcollection_extract(void) /* How to properly release 'col' ? * See http://http://trac.osgeo.org/postgis/ticket/1102 */ - lwfree(col); + lwcollection_free(col); lwgeom_free(geom); } diff --git a/liblwgeom/lwcollection.c b/liblwgeom/lwcollection.c index b681f80c6..b0d4b3b10 100644 --- a/liblwgeom/lwcollection.c +++ b/liblwgeom/lwcollection.c @@ -580,7 +580,7 @@ LWCOLLECTION* lwcollection_extract(LWCOLLECTION *col, int type) geomlistsize *= 2; geomlist = lwrealloc(geomlist, sizeof(LWGEOM*) * geomlistsize); } - geomlist[geomlistlen] = col->geoms[i]; + geomlist[geomlistlen] = lwgeom_clone(col->geoms[i]); geomlistlen++; } /* Recurse into sub-collections */