]> granicus.if.org Git - postgis/commitdiff
Protect ST_Segmentize from max_length=0 (#1799)
authorSandro Santilli <strk@keybit.net>
Fri, 4 May 2012 08:06:16 +0000 (08:06 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 4 May 2012 08:06:16 +0000 (08:06 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9712 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_basic.c
regress/tickets.sql
regress/tickets_expected

index 5a3398f175114f2bb033871d24906da08f2298ec..2e31c57da6e53b0fa8b18b938686bd06de51862f 100644 (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);
 
index fa07a57e0feec048d6327ea2b17c9b6d9822a59b..c6f0dfab0bdec9d7c8e3ed3e59811193d464f568 100644 (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;
index 50ee58d604c573b0bd80fec444a972f2a7b56359..31d24b6f3bba08fb8af42737e29a20ad17cc139c 100644 (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)