]> granicus.if.org Git - postgis/commitdiff
ST_GeomFromGeoJSON crash on empty rings
authorDarafei Praliaskouski <me@komzpa.net>
Sun, 4 Aug 2019 07:36:50 +0000 (07:36 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Sun, 4 Aug 2019 07:36:50 +0000 (07:36 +0000)
Closes #4470

git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17669 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/lwin_geojson.c
regress/in_geojson.sql
regress/in_geojson_expected

diff --git a/NEWS b/NEWS
index 2ddcfdcc56557be8831110e82e8d1e157becec90..41108aa481d907faf99e8be7f98deb041d519af5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,7 @@ PostGIS 2.5.3
   - #4437, Handle POINT EMPTY in shape loader/dumper (Paul Ramsey)
   - #4461, ST_AsTWKB doesn't always remove duplicate points (Nik Aven)
   - #4459, Fix ST_Subdivide crash on intermediate EMPTY (Darafei Praliaskouski)
-
+  - #4470, ST_GeomFromGeoJSON crash on empty rings (Darafei Praliaskouski)
 
 
 PostGIS 2.5.2
index bea570b077abdfd021bc6e538b86604a3775faae..5dbf00e5d7b4ca00561798598e84bcbeaa415afb 100644 (file)
@@ -262,9 +262,6 @@ parse_geojson_polygon(json_object *geojson, int *hasz, int root_srid)
                }
                nPoints = json_object_array_length(points);
 
-               /* Skip empty rings */
-               if ( nPoints == 0 ) continue;
-
                if ( ! ppa )
                        ppa = (POINTARRAY**)lwalloc(sizeof(POINTARRAY*) * nRings);
 
index e4c31292eee3146f35742ebfa6d5a11238431fba..6fffad06fca61171cefea25bd258f0eed29c2cfe 100644 (file)
@@ -52,3 +52,7 @@ SELECT '#3583', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon", "coordinat
 
 -- #4164
 SELECT ST_AsText(ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [[0,0],[0,5],[5, 5],[5,0],[0,0]]}'));
+SELECT '#4470.a', ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[0,0]],[]]}'));
+SELECT '#4470.b', ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[],[0,0]]}'));
+SELECT '#4470.c', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[0,0]],[]]]}'));
+SELECT '#4470.d', ST_AsText(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[],[0,0]]]}'));
index 03df63e9474c621c7a20a636edd96a248a737b3a..9d48f40a21cc91b8398704ed76723bac4228eb30 100644 (file)
@@ -31,3 +31,7 @@ geomfromgeojson_srs_3|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
 geomfromgeojson_srs_4|GEOMETRYCOLLECTION(POINT(100 0),LINESTRING(101 0,102 1))
 #3583|MULTIPOLYGON Z (EMPTY)
 ERROR:  The 'coordinates' in GeoJSON polygon are not sufficiently nested
+#4470.a|POLYGON((0 0),())
+ERROR:  The 'coordinates' in GeoJSON polygon are not sufficiently nested
+#4470.c|MULTIPOLYGON(((0 0),()))
+#4470.d|MULTIPOLYGON Z (EMPTY)