[postgis-tickets] r16725 - Parse error on incorrectly nested GeoJSON input
Paul Ramsey
pramsey at cleverelephant.ca
Mon Sep 10 03:19:00 PDT 2018
Author: pramsey
Date: 2018-09-10 15:19:00 -0700 (Mon, 10 Sep 2018)
New Revision: 16725
Modified:
trunk/liblwgeom/cunit/cu_in_geojson.c
trunk/liblwgeom/lwin_geojson.c
Log:
Parse error on incorrectly nested GeoJSON input
Closes #4164
Modified: trunk/liblwgeom/cunit/cu_in_geojson.c
===================================================================
--- trunk/liblwgeom/cunit/cu_in_geojson.c 2018-09-10 22:18:47 UTC (rev 16724)
+++ trunk/liblwgeom/cunit/cu_in_geojson.c 2018-09-10 22:19:00 UTC (rev 16725)
@@ -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: trunk/liblwgeom/lwin_geojson.c
===================================================================
--- trunk/liblwgeom/lwin_geojson.c 2018-09-10 22:18:47 UTC (rev 16724)
+++ trunk/liblwgeom/lwin_geojson.c 2018-09-10 22:19:00 UTC (rev 16725)
@@ -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