From: Sandro Santilli Date: Thu, 5 May 2011 21:12:49 +0000 (+0000) Subject: Do not attempt to read points from empty pointarrays (thanks valgrind for finding... X-Git-Tag: 2.0.0alpha1~1705 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ec29184a5cbb5bab29a56828598d1c4dd9e0cf5;p=postgis Do not attempt to read points from empty pointarrays (thanks valgrind for finding this) git-svn-id: http://svn.osgeo.org/postgis/trunk@7103 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwgunparse.c b/liblwgeom/lwgunparse.c index 438281f5d..6eb474bef 100644 --- a/liblwgeom/lwgunparse.c +++ b/liblwgeom/lwgunparse.c @@ -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;