From 3defae910a941604a72c1d2808eeb9e24a692efa Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Thu, 15 Aug 2019 17:00:19 +0000 Subject: [PATCH] Guard against reading into pointarrays when size of array == 0 git-svn-id: http://svn.osgeo.org/postgis/trunk@17716 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/gserialized1.c | 3 ++- liblwgeom/gserialized2.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/liblwgeom/gserialized1.c b/liblwgeom/gserialized1.c index 888228435..4b16aaa65 100644 --- a/liblwgeom/gserialized1.c +++ b/liblwgeom/gserialized1.c @@ -861,7 +861,8 @@ static size_t gserialized1_from_lwpoly(const LWPOLY *poly, uint8_t *buf) lwerror("Dimensions mismatch in lwpoly"); pasize = pa->npoints * ptsize; - memcpy(loc, getPoint_internal(pa, 0), pasize); + if ( pa->npoints > 0 ) + memcpy(loc, getPoint_internal(pa, 0), pasize); loc += pasize; } return (size_t)(loc - buf); diff --git a/liblwgeom/gserialized2.c b/liblwgeom/gserialized2.c index e6b6a76cd..da6adb84d 100644 --- a/liblwgeom/gserialized2.c +++ b/liblwgeom/gserialized2.c @@ -919,7 +919,8 @@ static size_t gserialized2_from_lwpoly(const LWPOLY *poly, uint8_t *buf) lwerror("Dimensions mismatch in lwpoly"); pasize = pa->npoints * ptsize; - memcpy(loc, getPoint_internal(pa, 0), pasize); + if ( pa->npoints > 0 ) + memcpy(loc, getPoint_internal(pa, 0), pasize); loc += pasize; } return (size_t)(loc - buf); @@ -1685,4 +1686,4 @@ GSERIALIZED* gserialized2_drop_gbox(GSERIALIZED *g) } return g_out; -} \ No newline at end of file +} -- 2.40.0