[postgis-tickets] r15487 - Credit to OSS-Fuzz
Regina Obe
lr at pcorp.us
Sun Jul 16 21:45:13 PDT 2017
Author: robe
Date: 2017-07-16 21:45:13 -0700 (Sun, 16 Jul 2017)
New Revision: 15487
Modified:
trunk/liblwgeom/ptarray.c
Log:
Credit to OSS-Fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2590
References #3786 for PostGIS 2.4/trunk
Modified: trunk/liblwgeom/ptarray.c
===================================================================
--- trunk/liblwgeom/ptarray.c 2017-07-17 01:36:23 UTC (rev 15486)
+++ trunk/liblwgeom/ptarray.c 2017-07-17 04:45:13 UTC (rev 15487)
@@ -679,6 +679,13 @@
int
ptarray_is_closed(const POINTARRAY *in)
{
+ if (!in)
+ {
+ lwerror("ptarray_is_closed: called with null point array");
+ return 0;
+ }
+ if (in->npoints <= 1 ) return in->npoints; /* single-point are closed, empty not closed */
+
return 0 == memcmp(getPoint_internal(in, 0), getPoint_internal(in, in->npoints-1), ptarray_point_size(in));
}
@@ -686,13 +693,27 @@
int
ptarray_is_closed_2d(const POINTARRAY *in)
{
- return 0 == memcmp(getPoint_internal(in, 0), getPoint_internal(in, in->npoints-1), sizeof(POINT2D));
+ if (!in)
+ {
+ lwerror("ptarray_is_closed_2d: called with null point array");
+ return 0;
+ }
+ if (in->npoints <= 1 ) return in->npoints; /* single-point are closed, empty not closed */
+
+ return 0 == memcmp(getPoint_internal(in, 0), getPoint_internal(in, in->npoints-1), sizeof(POINT2D) );
}
int
ptarray_is_closed_3d(const POINTARRAY *in)
{
- return 0 == memcmp(getPoint_internal(in, 0), getPoint_internal(in, in->npoints-1), sizeof(POINT3D));
+ if (!in)
+ {
+ lwerror("ptarray_is_closed_3d: called with null point array");
+ return 0;
+ }
+ if (in->npoints <= 1 ) return in->npoints; /* single-point are closed, empty not closed */
+
+ return 0 == memcmp(getPoint_internal(in, 0), getPoint_internal(in, in->npoints-1), sizeof(POINT3D) );
}
int
More information about the postgis-tickets
mailing list