[postgis-tickets] r17281 - Get rid of assert causing ST_3DMakeBox to crash
Regina Obe
lr at pcorp.us
Mon Feb 25 02:41:36 PST 2019
Author: robe
Date: 2019-02-25 14:41:36 -0800 (Mon, 25 Feb 2019)
New Revision: 17281
Modified:
trunk/NEWS
trunk/liblwgeom/lwgeom_api.c
trunk/postgis/lwgeom_box.c
trunk/postgis/lwgeom_box3d.c
trunk/regress/core/tickets.sql
trunk/regress/core/tickets_expected
Log:
Get rid of assert causing ST_3DMakeBox to crash
Change ST_3DMakeBox to throw an error when fed empty points instead of returning a philosophical answer to a stupid question
Change ST_MakeBox2D to return a more meaningful error instead waiting to fail when asking what is x of an empty point?
Closes #4331 for PostGIS 3.0
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/NEWS 2019-02-25 22:41:36 UTC (rev 17281)
@@ -19,6 +19,7 @@
and postgis.backend switch (Darafei Praliaskouski)
- #4267, Enable Proj 6 deprecated APIs (Darafei Praliaskouski, Raúl Marín)
- #4268, Bump minimum SFCGAL version to 1.3.1 (Darafei Praliaskouski)
+ - #4331, ST_3DMakeBox now returns error instead of a miniscule box (Regina Obe)
* New Features *
- #2902, postgis_geos_noop (Sandro Santilli)
Modified: trunk/liblwgeom/lwgeom_api.c
===================================================================
--- trunk/liblwgeom/lwgeom_api.c 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/liblwgeom/lwgeom_api.c 2019-02-25 22:41:36 UTC (rev 17281)
@@ -219,7 +219,7 @@
return 0;
}
- assert(n < pa->npoints);
+ //assert(n < pa->npoints); --causes point emtpy/point empty to crash
if ( n>=pa->npoints )
{
lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
Modified: trunk/postgis/lwgeom_box.c
===================================================================
--- trunk/postgis/lwgeom_box.c 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/postgis/lwgeom_box.c 2019-02-25 22:41:36 UTC (rev 17281)
@@ -543,10 +543,15 @@
if ( (minpoint->type != POINTTYPE) || (maxpoint->type != POINTTYPE) )
{
- elog(ERROR, "GBOX_construct: arguments must be points");
+ elog(ERROR, "BOX2D_construct: arguments must be points");
PG_RETURN_NULL();
}
+ if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
+ elog(ERROR, "BOX2D_construct: args can not be empty points");
+ PG_RETURN_NULL();
+ }
+
error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
result = gbox_new(gflags(0, 0, 0));
Modified: trunk/postgis/lwgeom_box3d.c
===================================================================
--- trunk/postgis/lwgeom_box3d.c 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/postgis/lwgeom_box3d.c 2019-02-25 22:41:36 UTC (rev 17281)
@@ -565,6 +565,11 @@
PG_RETURN_NULL();
}
+ if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
+ elog(ERROR, "BOX3D_construct: args can not be empty points");
+ PG_RETURN_NULL();
+ }
+
error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
Modified: trunk/regress/core/tickets.sql
===================================================================
--- trunk/regress/core/tickets.sql 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/regress/core/tickets.sql 2019-02-25 22:41:36 UTC (rev 17281)
@@ -1125,7 +1125,11 @@
ST_Distance(ST_GeometryN(ST_GeneratePoints(g, 1000, 12345), 1000), 'POINT(0.801167838758 0.345281131175)'::geometry) < 1e-11
FROM (SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry AS g) AS f;
+-- #4331
+SELECT '#4304a', ST_3DMakeBox(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
+SELECT '#4304b', ST_MakeBox2D(ST_GeomFromText('POINT EMPTY',4326), ST_GeomFromText('POINT EMPTY',4326)) IS NULL;
+
-- Clean up
DELETE FROM spatial_ref_sys;
Modified: trunk/regress/core/tickets_expected
===================================================================
--- trunk/regress/core/tickets_expected 2019-02-25 19:13:36 UTC (rev 17280)
+++ trunk/regress/core/tickets_expected 2019-02-25 22:41:36 UTC (rev 17281)
@@ -340,4 +340,6 @@
NOTICE: table "bug_4144_table" does not exist, skipping
#4299|t
#4304|t|t|t|t
+ERROR: BOX3D_construct: args can not be empty points
+ERROR: BOX2D_construct: args can not be empty points
#4176|t
More information about the postgis-tickets
mailing list