From: Olivier Courtin Date: Mon, 6 Feb 2012 21:15:33 +0000 (+0000) Subject: Fix a bug in tgeom_free, related to #665 X-Git-Tag: 2.0.0alpha4~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ffd119683a1c42f500f7ab10f65d9a172af73ba;p=postgis Fix a bug in tgeom_free, related to #665 git-svn-id: http://svn.osgeo.org/postgis/trunk@9053 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_surface.c b/liblwgeom/cunit/cu_surface.c index 614751cb3..abc196f85 100644 --- a/liblwgeom/cunit/cu_surface.c +++ b/liblwgeom/cunit/cu_surface.c @@ -284,7 +284,6 @@ check_tgeom(char *ewkt, int type, uint32_t srid, int is_solid) CU_ASSERT(lwgeom_same(g1, g2)); lwgeom_free(g2); -#if 0 tser = tgeom_serialize(tgeom); tgeom2 = tgeom_deserialize(tser); g2 = lwgeom_from_tgeom(tgeom2); @@ -307,8 +306,6 @@ check_tgeom(char *ewkt, int type, uint32_t srid, int is_solid) lwfree(tser); tgeom_free(tgeom2); lwgeom_free(g2); -#endif - tgeom_free(tgeom); lwgeom_free(g1); } @@ -515,6 +512,7 @@ psurface_tgeom(void) check_tgeom("POLYHEDRALSURFACE(((0 1 2 3,4 5 6 7,8 9 10 11,0 1 2 3),(12 13 14 15,16 17 18 19,20 21 22 23,12 13 14 15),(16 17 18 19,20 21 22 23,24 25 26 27,16 17 18 19)))", POLYHEDRALSURFACETYPE, 0, 0); #endif + } diff --git a/liblwgeom/libtgeom.c b/liblwgeom/libtgeom.c index af9417b66..574b503c6 100644 --- a/liblwgeom/libtgeom.c +++ b/liblwgeom/libtgeom.c @@ -379,7 +379,7 @@ tgeom_free(TGEOM *tgeom) /* rings */ for (j=0 ; j < tgeom->faces[i]->nrings ; j++) ptarray_free(tgeom->faces[i]->rings[j]); - if (tgeom->faces[i]->rings) + if (tgeom->faces[i]->nrings) lwfree(tgeom->faces[i]->rings); lwfree(tgeom->faces[i]); @@ -599,8 +599,8 @@ tgeom_serialize_size(const TGEOM *tgeom) int dims = FLAGS_NDIMS(tgeom->flags); size = sizeof(uint8_t); /* type */ - size += sizeof(uint8_t); /* flags */ - size += sizeof(uint32_t); /* srid */ + size += sizeof(uint8_t); /* flags */ + size += sizeof(uint32_t); /* srid */ if (tgeom->bbox) size += sizeof(BOX3D); /* bbox */ size += sizeof(int); /* nedges */ @@ -752,7 +752,6 @@ tgeom_serialize(const TGEOM *tgeom) size_t size, retsize; TSERIALIZED * t; uint8_t *data; - size = tgeom_serialize_size(tgeom); data = lwalloc(size); tgeom_serialize_buf(tgeom, data, &retsize); @@ -778,6 +777,7 @@ tgeom_serialize(const TGEOM *tgeom) } + /* * Deserialize a TSERIALIZED struct and * return a TGEOM pointer