Protect ST_Segmentize from max_length=0 (#1799)

git-svn-id: http://svn.osgeo.org/postgis/trunk@9712 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2012-05-04 08:06:16 +00:00
parent 4b969d32a9
commit 4ef0b834d7
3 changed files with 11 additions and 0 deletions

View file

@ -1824,6 +1824,13 @@ Datum LWGEOM_segmentize2d(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(ingeom);
}
if ( dist <= 0 ) {
/* Protect from knowingly infinite loops, see #1799 */
/* Note that we'll end out of memory anyway for other small distances */
elog(ERROR, "ST_Segmentize: invalid max_distance %g (must be >= 0)", dist);
PG_RETURN_NULL();
}
inlwgeom = lwgeom_from_gserialized(ingeom);
outlwgeom = lwgeom_segmentize2d(inlwgeom, dist);

View file

@ -677,5 +677,8 @@ with inp as ( SELECT
) SELECT '#1791', round(ST_Azimuth(a,b)*10)/10 from inp;
-- #1799 --
SELECT '#1799', ST_Segmentize('LINESTRING(0 0, 10 0)'::geometry, 0);
-- Clean up
DELETE FROM spatial_ref_sys;

View file

@ -219,3 +219,4 @@ NOTICE: SRID value -1 converted to the officially unknown SRID value 0
#1755|01010000A0E6100000000000000040554000000000008041400000000000000000
#1776|POLYGON((0 0,10 0,10 10,0 0))|POLYGON((0 0,10 0,10 10,0 0))
#1791|4.7
ERROR: ST_Segmentize: invalid max_distance 0 (must be >= 0)