From: Darafei Praliaskouski Date: Sun, 4 Aug 2019 07:36:50 +0000 (+0000) Subject: ST_GeomFromGeoJSON crash on empty rings X-Git-Tag: 2.5.3~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc1e0be43960d0b24974ac2c0e102f32368f984d;p=postgis ST_GeomFromGeoJSON crash on empty rings Closes #4470 git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17669 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 2ddcfdcc5..41108aa48 100644 --- 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 diff --git a/liblwgeom/lwin_geojson.c b/liblwgeom/lwin_geojson.c index bea570b07..5dbf00e5d 100644 --- a/liblwgeom/lwin_geojson.c +++ b/liblwgeom/lwin_geojson.c @@ -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); diff --git a/regress/in_geojson.sql b/regress/in_geojson.sql index e4c31292e..6fffad06f 100644 --- a/regress/in_geojson.sql +++ b/regress/in_geojson.sql @@ -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]]]}')); diff --git a/regress/in_geojson_expected b/regress/in_geojson_expected index 03df63e94..9d48f40a2 100644 --- a/regress/in_geojson_expected +++ b/regress/in_geojson_expected @@ -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)