[postgis-commits] svn - r3803 - trunk/liblwgeom
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Sun Mar 8 08:37:28 PDT 2009
Author: pramsey
Date: 2009-03-08 08:37:27 -0700 (Sun, 08 Mar 2009)
New Revision: 3803
Modified:
trunk/liblwgeom/lwgeom_api.c
Log:
Fix for GBT #116, EMPTY hex polygon no longer causes crash.
Modified: trunk/liblwgeom/lwgeom_api.c
===================================================================
--- trunk/liblwgeom/lwgeom_api.c 2009-03-08 14:36:05 UTC (rev 3802)
+++ trunk/liblwgeom/lwgeom_api.c 2009-03-08 15:37:27 UTC (rev 3803)
@@ -1645,8 +1645,8 @@
{
int type = lwgeom_getType(srl[0]);
int t;
- uchar *loc;
- uint32 ngeoms;
+ uchar *loc = srl;
+ uint32 nelems;
BOX3D *result;
BOX3D b1;
int sub_size;
@@ -1654,6 +1654,23 @@
LWDEBUGF(2, "compute_serialized_box3d called on type %d", type);
+ loc += 1; /* Move past the 'type' byte. */
+
+ if (lwgeom_hasBBOX(srl[0]))
+ {
+ loc += sizeof(BOX2DFLOAT4); /* Move past the bbox */
+ }
+
+ if (lwgeom_hasSRID(srl[0]) )
+ {
+ loc +=4; /* Move past the SRID */
+ }
+
+ nelems = lw_get_uint32(loc);
+
+ /* No elements? This is an EMPTY geometry. */
+ if ( nelems == 0 ) return NULL;
+
if (type == POINTTYPE)
{
LWPOINT *pt = lwpoint_deserialize(srl);
@@ -1700,24 +1717,11 @@
return NULL;
}
- loc = srl+1;
-
- if (lwgeom_hasBBOX(srl[0]))
- {
- loc += sizeof(BOX2DFLOAT4);
- }
-
- if (lwgeom_hasSRID(srl[0]) )
- {
- loc +=4;
- }
-
- ngeoms = lw_get_uint32(loc);
loc += 4;
/* each sub-type */
result = NULL;
- for (t=0; t<ngeoms; t++)
+ for (t=0; t<nelems; t++)
{
if ( compute_serialized_box3d_p(loc, &b1) )
{
More information about the postgis-commits
mailing list