[postgis-tickets] r14919 - #3565, st_setpoint crashes database

Paul Ramsey pramsey at cleverelephant.ca
Wed May 25 10:28:25 PDT 2016


Author: pramsey
Date: 2016-05-25 10:28:25 -0700 (Wed, 25 May 2016)
New Revision: 14919

Modified:
   branches/2.1/NEWS
   branches/2.1/postgis/lwgeom_functions_basic.c
   branches/2.1/regress/tickets.sql
   branches/2.1/regress/tickets_expected
Log:
#3565, st_setpoint crashes database



Modified: branches/2.1/NEWS
===================================================================
--- branches/2.1/NEWS	2016-05-25 17:28:18 UTC (rev 14918)
+++ branches/2.1/NEWS	2016-05-25 17:28:25 UTC (rev 14919)
@@ -27,6 +27,7 @@
            innerBoundaryIs and no outerBoundaryIs
   - #3429, upgrading to 2.2 or 2.3 can cause crash/hang on some 
            platforms
+  - #3565, ST_SetPoint can crash backend
 
 
 PostGIS 2.1.8

Modified: branches/2.1/postgis/lwgeom_functions_basic.c
===================================================================
--- branches/2.1/postgis/lwgeom_functions_basic.c	2016-05-25 17:28:18 UTC (rev 14918)
+++ branches/2.1/postgis/lwgeom_functions_basic.c	2016-05-25 17:28:25 UTC (rev 14919)
@@ -2330,6 +2330,11 @@
 		elog(ERROR, "First argument must be a LINESTRING");
 		PG_RETURN_NULL();
 	}
+	if ( lwgeom_is_empty(lwg) )
+	{
+		elog(ERROR, "Cannot set point values on EMPTY geometry, use ST_AddPoint to add points");
+		PG_RETURN_NULL();
+	}
 	if ( which > line->points->npoints-1 )
 	{
 		elog(ERROR, "Point index out of range (%d..%d)", 0, line->points->npoints-1);

Modified: branches/2.1/regress/tickets.sql
===================================================================
--- branches/2.1/regress/tickets.sql	2016-05-25 17:28:18 UTC (rev 14918)
+++ branches/2.1/regress/tickets.sql	2016-05-25 17:28:25 UTC (rev 14919)
@@ -883,5 +883,8 @@
 SELECT '#3375', ST_AsText(ST_RemoveRepeatedPoints('GEOMETRYCOLLECTION(POINT(1 1))'::geometry));
 
 
+-- #3565
+SELECT '#3565',ST_SetPoint(st_geomfromtext('LINESTRING EMPTY'), 0, ST_MakePoint(1,1));
+
 -- Clean up
 DELETE FROM spatial_ref_sys;

Modified: branches/2.1/regress/tickets_expected
===================================================================
--- branches/2.1/regress/tickets_expected	2016-05-25 17:28:18 UTC (rev 14918)
+++ branches/2.1/regress/tickets_expected	2016-05-25 17:28:25 UTC (rev 14919)
@@ -261,3 +261,4 @@
 #2870|Point[GS]
 #3367|POLYGON EMPTY
 #3375|GEOMETRYCOLLECTION(POINT(1 1))
+ERROR:  Cannot set point values on EMPTY geometry, use ST_AddPoint to add points



More information about the postgis-tickets mailing list