[postgis-tickets] r16724 - Parse error on incorrectly nested GeoJSON input
Paul Ramsey
pramsey at cleverelephant.ca
Mon Sep 10 03:18:48 PDT 2018
Author: pramsey
Date: 2018-09-10 15:18:47 -0700 (Mon, 10 Sep 2018)
New Revision: 16724
Modified:
branches/2.5/liblwgeom/cunit/cu_in_geojson.c
branches/2.5/liblwgeom/lwin_geojson.c
Log:
Parse error on incorrectly nested GeoJSON input
References #4164
Modified: branches/2.5/liblwgeom/cunit/cu_in_geojson.c
===================================================================
--- branches/2.5/liblwgeom/cunit/cu_in_geojson.c 2018-09-07 11:19:22 UTC (rev 16723)
+++ branches/2.5/liblwgeom/cunit/cu_in_geojson.c 2018-09-10 22:18:47 UTC (rev 16724)
@@ -151,6 +151,13 @@
static void in_geojson_test_geoms(void)
{
+
+ /* Incorrect Polygon (#4164) */
+ // do_geojson_test(
+ // "POLYGON((0 0,0 5,5 5,5 0,0 0))",
+ // "{\"type\": \"Polygon\", \"coordinates\": [[0,0],[0,5],[5, 5],[5,0],[0,0]]}",
+ // NULL);
+
/* Linestring */
do_geojson_test(
"LINESTRING(0 1,2 3,4 5)",
Modified: branches/2.5/liblwgeom/lwin_geojson.c
===================================================================
--- branches/2.5/liblwgeom/lwin_geojson.c 2018-09-07 11:19:22 UTC (rev 16723)
+++ branches/2.5/liblwgeom/lwin_geojson.c 2018-09-10 22:18:47 UTC (rev 16724)
@@ -273,7 +273,17 @@
{
json_object* coords = NULL;
coords = json_object_array_get_idx( points, j );
- parse_geojson_coord(coords, hasz, ppa[i]);
+ if (LW_FAILURE == parse_geojson_coord(coords, hasz, ppa[i]))
+ {
+ int k;
+ for (k = 0; k <= i; k++)
+ {
+ ptarray_free(ppa[k]);
+ }
+ lwfree(ppa);
+ geojson_lwerror("The 'coordinates' in GeoJSON polygon are not sufficiently nested", 4);
+ return NULL;
+ }
}
}
More information about the postgis-tickets
mailing list