]> granicus.if.org Git - postgis/commitdiff
Guard against reading into pointarrays when size of array == 0
authorPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 15 Aug 2019 17:00:19 +0000 (17:00 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Thu, 15 Aug 2019 17:00:19 +0000 (17:00 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@17716 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/gserialized1.c
liblwgeom/gserialized2.c

index 8882284352ab24ee034e969ef7970efbdf11ab46..4b16aaa65799e9d94d9145cabba06f7cac730a6f 100644 (file)
@@ -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);
index e6b6a76cdbe5e19a77e654928bf64b3bfec66927..da6adb84d66db1e4648cf7d1d9a3096580d8ca2d 100644 (file)
@@ -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
+}