]> granicus.if.org Git - postgis/commitdiff
Do not attempt to read points from empty pointarrays (thanks valgrind for finding...
authorSandro Santilli <strk@keybit.net>
Thu, 5 May 2011 21:12:49 +0000 (21:12 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 5 May 2011 21:12:49 +0000 (21:12 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7103 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgunparse.c

index 438281f5da525fdda305bd1f201ffa230697a41e..6eb474bef52f6102af9cedb5c5f3ed6ea15fa5fb 100644 (file)
@@ -873,9 +873,6 @@ output_wkb_polygon_ring_collection(uchar* geom,outwkbfunc func)
        int cnt;
        int orig_cnt;
 
-       first_point = lwalloc(dims * sizeof(double));
-       last_point = lwalloc(dims * sizeof(double));
-
        cnt = read_int(&geom);
        orig_cnt = cnt;
 
@@ -883,6 +880,11 @@ output_wkb_polygon_ring_collection(uchar* geom,outwkbfunc func)
 
        write_wkb_int(cnt);
 
+       if ( ! cnt ) return geom;
+
+       first_point = lwalloc(dims * sizeof(double));
+       last_point = lwalloc(dims * sizeof(double));
+
        /* Store the first point of the ring (use a temp var since read_double alters
           the pointer after use) */
        temp = geom;