(NULL == CU_add_test(pSuite, "test_lwgeom_count_vertices()", test_lwgeom_count_vertices)) ||
(NULL == CU_add_test(pSuite, "test_on_gser_lwgeom_count_vertices()", test_on_gser_lwgeom_count_vertices)) ||
(NULL == CU_add_test(pSuite, "test_geometry_type_from_string()", test_geometry_type_from_string)) ||
- (NULL == CU_add_test(pSuite, "test_lwcollection_extract()", test_lwcollection_extract))
+ (NULL == CU_add_test(pSuite, "test_lwcollection_extract()", test_lwcollection_extract)) ||
+ (NULL == CU_add_test(pSuite, "test_lwgeom_free()", test_lwgeom_free))
)
{
lwgeom_free(geom);
}
+
+void test_lwgeom_free(void)
+{
+ LWGEOM *geom;
+
+ /* Empty geometries don't seem to free properly (#370) */
+ geom = lwgeom_from_ewkt("GEOMETRYCOLLECTION EMPTY", PARSER_CHECK_NONE);
+ CU_ASSERT_EQUAL(TYPE_GETTYPE(geom->type), COLLECTIONTYPE);
+ lwgeom_free(geom);
+
+ /* Empty geometries don't seem to free properly (#370) */
+ geom = lwgeom_from_ewkt("POLYGON EMPTY", PARSER_CHECK_NONE);
+ CU_ASSERT_EQUAL(TYPE_GETTYPE(geom->type), COLLECTIONTYPE);
+ lwgeom_free(geom);
+
+ /* Empty geometries don't seem to free properly (#370) */
+ geom = lwgeom_from_ewkt("LINESTRING EMPTY", PARSER_CHECK_NONE);
+ CU_ASSERT_EQUAL(TYPE_GETTYPE(geom->type), COLLECTIONTYPE);
+ lwgeom_free(geom);
+
+ /* Empty geometries don't seem to free properly (#370) */
+ geom = lwgeom_from_ewkt("POINT EMPTY", PARSER_CHECK_NONE);
+ CU_ASSERT_EQUAL(TYPE_GETTYPE(geom->type), COLLECTIONTYPE);
+ lwgeom_free(geom);
+
+}
*/
-
/* Test functions */
void test_typmod_macros(void);
void test_flags_macros(void);
void test_lwcollection_extract(void);
void test_lwgeom_count_vertices(void);
void test_on_gser_lwgeom_count_vertices(void);
-
+void test_lwgeom_free(void);
result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
memcpy(result->bbox, srl+1, sizeof(BOX2DFLOAT4));
}
- else result->bbox = NULL;
+ else
+ {
+ result->bbox = NULL;
+ }
if ( insp->ngeometries )
result->geoms[i] = lwgeom_deserialize(insp->sub_geoms[i]);
}
}
+ else
+ {
+ result->geoms = NULL;
+ }
return result;
}
result->type = insp->type;
result->SRID = insp->SRID;
result->ngeoms = insp->ngeometries;
- result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
+
+ if( insp->ngeometries )
+ {
+ result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
+ }
+ else
+ {
+ result->geoms = NULL;
+ }
if (lwgeom_hasBBOX(srl[0]))
{
result->type = insp->type;
result->SRID = insp->SRID;
result->ngeoms = insp->ngeometries;
- result->geoms = lwalloc(sizeof(LWLINE *)*insp->ngeometries);
+
+ if( insp->ngeometries )
+ {
+ result->geoms = lwalloc(sizeof(LWLINE *)*insp->ngeometries);
+ }
+ else
+ {
+ result->geoms = NULL;
+ }
if (lwgeom_hasBBOX(srl[0]))
{
result->type = insp->type;
result->SRID = insp->SRID;
result->ngeoms = insp->ngeometries;
- result->geoms = lwalloc(sizeof(LWPOINT *)*result->ngeoms);
+
+ if ( insp->ngeometries )
+ {
+ result->geoms = lwalloc(sizeof(LWPOINT *)*insp->ngeometries);
+ }
+ else
+ {
+ result->geoms = NULL;
+ }
if (lwgeom_hasBBOX(srl[0]))
{
result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
memcpy(result->bbox, srl+1, sizeof(BOX2DFLOAT4));
}
- else result->bbox = NULL;
+ else
+ {
+ result->bbox = NULL;
+ }
for (i=0; i<insp->ngeometries; i++)
{
result->type = insp->type;
result->SRID = insp->SRID;
result->ngeoms = insp->ngeometries;
- result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
+
+ if( insp->ngeometries )
+ {
+ result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
+ }
+ else
+ {
+ result->geoms = NULL;
+ }
if (lwgeom_hasBBOX(srl[0]))
{
result->type = insp->type;
result->SRID = insp->SRID;
result->ngeoms = insp->ngeometries;
- result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
+
+ if( insp->ngeometries )
+ {
+ result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
+ }
+ else
+ {
+ result->geoms = NULL;
+ }
if (lwgeom_hasBBOX(srl[0]))
{
nrings = lw_get_uint32(loc);
result->nrings = nrings;
loc +=4;
- result->rings = (POINTARRAY**) lwalloc(nrings* sizeof(POINTARRAY*));
+ if( nrings )
+ {
+ result->rings = (POINTARRAY**) lwalloc(nrings* sizeof(POINTARRAY*));
+ }
+ else
+ {
+ result->rings = NULL;
+ }
for (t =0;t<nrings;t++)
{