From: Sandro Santilli Date: Mon, 3 Dec 2012 16:19:04 +0000 (+0000) Subject: Fix memory error in MultiPolygon GeoJson parsing (#2130) X-Git-Tag: 2.1.0beta2~329 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d5b47b4c492dd8023ec9b7fa81457753a1607ac;p=postgis Fix memory error in MultiPolygon GeoJson parsing (#2130) git-svn-id: http://svn.osgeo.org/postgis/trunk@10786 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_in_geojson.c b/postgis/lwgeom_in_geojson.c index d3970da43..f42202e66 100644 --- a/postgis/lwgeom_in_geojson.c +++ b/postgis/lwgeom_in_geojson.c @@ -376,7 +376,7 @@ parse_geojson_multipolygon(json_object *geojson, bool *hasz, int *root_srid) { int nPoints; ppa = (POINTARRAY**) lwrealloc((POINTARRAY *) ppa, sizeof(POINTARRAY*) * (j + 1)); - ppa[i] = ptarray_construct_empty(1, 0, 1); + ppa[j] = ptarray_construct_empty(1, 0, 1); points = json_object_array_get_idx( poObjPoly, j ); nPoints = json_object_array_length( points ); diff --git a/regress/tickets.sql b/regress/tickets.sql index bb050b03f..d902cf18e 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -791,5 +791,7 @@ FROM (SELECT 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry as a, 'LINES SELECT '#2108', ST_AsEWKT(ST_Line_Interpolate_Point('SRID=3395;LINESTRING M EMPTY'::geometry, 0.5)); SELECT '#2117', ST_AsEWKT(ST_PointOnSurface('SRID=3395;MULTIPOLYGON M EMPTY'::geometry)); +SELECT '#2130', ST_NPoints(ST_GeomFromGeoJSON('{"type":"MultiPolygon","coordinates":[[[[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,32],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,32],[-117,32],[-117,32],[-117,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-116,32],[-117,32],[-117,32],[-117,32],[-117,32]],[[-117,33],[-117,33],[-117,33],[-117,33],[-117,33],[-117,32],[-117,33]]]]}')); + -- Clean up DELETE FROM spatial_ref_sys; diff --git a/regress/tickets_expected b/regress/tickets_expected index e0f691fa2..e7f22f88b 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -242,3 +242,4 @@ ERROR: invalid GML representation #2112b|1|LINESTRING(1 1 1,1 0 1) #2108|SRID=3395;POINTM EMPTY #2117|SRID=3395;POINTM EMPTY +#2130|8