[postgis-tickets] r14430 - #3375, repeated points crash

Paul Ramsey pramsey at cleverelephant.ca
Wed Nov 25 13:45:50 PST 2015


Author: pramsey
Date: 2015-11-25 13:45:50 -0800 (Wed, 25 Nov 2015)
New Revision: 14430

Modified:
   branches/2.1/NEWS
   branches/2.1/liblwgeom/lwgeom.c
   branches/2.1/regress/tickets.sql
   branches/2.1/regress/tickets_expected
Log:
#3375, repeated points crash


Modified: branches/2.1/NEWS
===================================================================
--- branches/2.1/NEWS	2015-11-25 21:40:22 UTC (rev 14429)
+++ branches/2.1/NEWS	2015-11-25 21:45:50 UTC (rev 14430)
@@ -16,7 +16,9 @@
            always return false as result.
   - #3359, Fix toTopoGeom loss of low-id primitives from TopoGeometry
            definition
+  - #3375, crash in repeated point removal for collection(point)
 
+
 PostGIS 2.1.8
 2015/07/07
 

Modified: branches/2.1/liblwgeom/lwgeom.c
===================================================================
--- branches/2.1/liblwgeom/lwgeom.c	2015-11-25 21:40:22 UTC (rev 14429)
+++ branches/2.1/liblwgeom/lwgeom.c	2015-11-25 21:45:50 UTC (rev 14430)
@@ -1341,6 +1341,11 @@
 	LWDEBUGF(4, "lwgeom_remove_repeated_points got type %s",
 	         lwtype_name(in->type));
 
+	if(lwgeom_is_empty(in)) 
+	{
+		return lwgeom_clone_deep(in);
+	}
+
 	switch (in->type)
 	{
 	case MULTIPOINTTYPE:
@@ -1363,7 +1368,7 @@
 	case TRIANGLETYPE:
 	case TINTYPE:
 		/* No point is repeated for a single point, or for Triangle or TIN */
-		return in;
+		return lwgeom_clone_deep(in);
 
 	case CIRCSTRINGTYPE:
 	case COMPOUNDTYPE:
@@ -1371,12 +1376,12 @@
 	case CURVEPOLYTYPE:
 	case MULTISURFACETYPE:
 		/* Dunno how to handle these, will return untouched */
-		return in;
+		return lwgeom_clone_deep(in);
 
 	default:
 		lwnotice("lwgeom_remove_repeated_points: unsupported geometry type: %s",
 		         lwtype_name(in->type));
-		return in;
+		return lwgeom_clone_deep(in);
 		break;
 	}
 	return 0;

Modified: branches/2.1/regress/tickets.sql
===================================================================
--- branches/2.1/regress/tickets.sql	2015-11-25 21:40:22 UTC (rev 14429)
+++ branches/2.1/regress/tickets.sql	2015-11-25 21:45:50 UTC (rev 14430)
@@ -879,5 +879,9 @@
 SELECT '#2788', valid, reason, ST_AsText(location) from ST_IsValidDetail('POLYGON((0 0, 0 1, 2 1, 2 2, 1 2, 1 0, 0 0))'::geometry);
 SELECT '#2870', ST_Summary('Point(151.215289 -33.856885)'::geometry::bytea::geography);
 
+SELECT '#3367', ST_AsText(ST_RemoveRepeatedPoints('POLYGON EMPTY'::geometry));
+SELECT '#3375', ST_AsText(ST_RemoveRepeatedPoints('GEOMETRYCOLLECTION(POINT(1 1))'::geometry));
+
+
 -- Clean up
 DELETE FROM spatial_ref_sys;

Modified: branches/2.1/regress/tickets_expected
===================================================================
--- branches/2.1/regress/tickets_expected	2015-11-25 21:40:22 UTC (rev 14429)
+++ branches/2.1/regress/tickets_expected	2015-11-25 21:45:50 UTC (rev 14430)
@@ -259,3 +259,5 @@
 #2712|LINESTRING EMPTY
 #2788|f|Self-intersection|POINT(1 1)
 #2870|Point[GS]
+#3367|POLYGON EMPTY
+#3375|GEOMETRYCOLLECTION(POINT(1 1))



More information about the postgis-tickets mailing list