]> granicus.if.org Git - postgis/commitdiff
Fix uninitialized read in GeoJSON parser (#1829)
authorSandro Santilli <strk@keybit.net>
Fri, 18 May 2012 09:59:13 +0000 (09:59 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 18 May 2012 09:59:13 +0000 (09:59 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9753 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
postgis/lwgeom_in_geojson.c

diff --git a/NEWS b/NEWS
index 1ffdfcdbe46bc725d11904dff8800d1b69c0ed4f..c9a7146c02118469a7381efa6363d68ff74e3356 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,7 @@ PostGIS 2.0.1
   - #1819, fix floating point issues with ST_World2RasterCoord and
     ST_Raster2WorldCoord variants.
   - #1825, fix prepared geometry cache lookup
+  - #1829, fix uninitialized read in GeoJSON parser
 
 * Enhancements *
 
index 1f2fcdb1ff5e3a5c63eafabc8066288dea486c2c..fc912249b9c336e33050ab2cd93e81f5ccfb80f0 100644 (file)
@@ -101,9 +101,7 @@ parse_geojson_coord(json_object *poObj, bool *hasz, POINTARRAY *pa)
                        pt.y = json_object_get_int( poObjCoord );
                POSTGIS_DEBUGF(3, "parse_geojson_coord pt.y = %f.", pt.y );
 
-               *hasz = false;
-
-               if( nSize == 3 )
+               if( nSize == 3 ) /* should this be >= 3 ? */
                {
                        // Read Z coordiante
                        poObjCoord = json_object_array_get_idx( poObj, 2 );
@@ -114,6 +112,18 @@ parse_geojson_coord(json_object *poObj, bool *hasz, POINTARRAY *pa)
                        POSTGIS_DEBUGF(3, "parse_geojson_coord pt.z = %f.", pt.z );
                        *hasz = true;
                }
+               else
+               {
+                       *hasz = false;
+                       /* Initialize Z coordinate, if required */
+                       if ( FLAGS_GET_Z(pa->flags) ) pt.z = 0.0;
+               }
+
+               /* TODO: should we account for nSize > 3 ? */
+
+               /* Initialize M coordinate, if required */
+               if ( FLAGS_GET_M(pa->flags) ) pt.m = 0.0;
+
        }
 
        return ptarray_append_point(pa, &pt, LW_FALSE);