[postgis-tickets] r17669 - ST_GeomFromGeoJSON crash on empty rings

Darafei komzpa at gmail.com
Sun Aug 4 12:36:51 PDT 2019


Author: komzpa
Date: 2019-08-04 00:36:50 -0700 (Sun, 04 Aug 2019)
New Revision: 17669

Modified:
   branches/2.5/NEWS
   branches/2.5/liblwgeom/lwin_geojson.c
   branches/2.5/regress/in_geojson.sql
   branches/2.5/regress/in_geojson_expected
Log:
ST_GeomFromGeoJSON crash on empty rings

Closes #4470


Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2019-08-04 07:19:22 UTC (rev 17668)
+++ branches/2.5/NEWS	2019-08-04 07:36:50 UTC (rev 17669)
@@ -18,9 +18,9 @@
   - #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
 2019/03/11
 

Modified: branches/2.5/liblwgeom/lwin_geojson.c
===================================================================
--- branches/2.5/liblwgeom/lwin_geojson.c	2019-08-04 07:19:22 UTC (rev 17668)
+++ branches/2.5/liblwgeom/lwin_geojson.c	2019-08-04 07:36:50 UTC (rev 17669)
@@ -262,9 +262,6 @@
 		}
 		nPoints = json_object_array_length(points);
 
-		/* Skip empty rings */
-		if ( nPoints == 0 ) continue;
-
 		if ( ! ppa )
 			ppa = (POINTARRAY**)lwalloc(sizeof(POINTARRAY*) * nRings);
 

Modified: branches/2.5/regress/in_geojson.sql
===================================================================
--- branches/2.5/regress/in_geojson.sql	2019-08-04 07:19:22 UTC (rev 17668)
+++ branches/2.5/regress/in_geojson.sql	2019-08-04 07:36:50 UTC (rev 17669)
@@ -52,3 +52,7 @@
 
 -- #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]]]}'));

Modified: branches/2.5/regress/in_geojson_expected
===================================================================
--- branches/2.5/regress/in_geojson_expected	2019-08-04 07:19:22 UTC (rev 17668)
+++ branches/2.5/regress/in_geojson_expected	2019-08-04 07:36:50 UTC (rev 17669)
@@ -31,3 +31,7 @@
 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)



More information about the postgis-tickets mailing list