From: Sandro Santilli Date: Fri, 25 Nov 2005 15:27:39 +0000 (+0000) Subject: Fixed 0-size allocation in lwcollection deserializer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f36930023e567d1fe9e2fc12e8acefaf7a2434c4;p=postgis Fixed 0-size allocation in lwcollection deserializer (only matters when backend is compiled with --enable-cassert) git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@2070 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/CHANGES b/CHANGES index 499984a05..8b8a0f848 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +PostGIS 1.0.6CVS + - Fixed palloc(0) call in collection deserializer (only gives + problem with --enable-cassert) + PostGIS 1.0.5 2005/11/25 - New "Reporting Bugs" chapter in manual diff --git a/lwgeom/lwcollection.c b/lwgeom/lwcollection.c index c6f62c1a6..edbab1ef5 100644 --- a/lwgeom/lwcollection.c +++ b/lwgeom/lwcollection.c @@ -84,7 +84,6 @@ lwcollection_deserialize(uchar *srl) result->type = typefl; result->SRID = insp->SRID; result->ngeoms = insp->ngeometries; - result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries); if (lwgeom_hasBBOX(srl[0])) { @@ -95,9 +94,14 @@ lwcollection_deserialize(uchar *srl) else result->bbox = NULL; - for (i=0; ingeometries; i++) + if ( insp->ngeometries ) { - result->geoms[i] = lwgeom_deserialize(insp->sub_geoms[i]); + result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries); + for (i=0; ingeometries; i++) + { + result->geoms[i] = + lwgeom_deserialize(insp->sub_geoms[i]); + } } return result;