From d0b5696a07ea5cbcf17353276bcd076a2edc7ddf Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 13 Oct 2013 21:57:50 -0300 Subject: [PATCH] poly2d/f2d_tri_holes.cpp (find_point): don't loop forever on closed polygons --- poly2d/f2d_tri_holes.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/poly2d/f2d_tri_holes.cpp b/poly2d/f2d_tri_holes.cpp index 37844ac..e8406bd 100644 --- a/poly2d/f2d_tri_holes.cpp +++ b/poly2d/f2d_tri_holes.cpp @@ -169,11 +169,15 @@ void insert_polygon(CDT &cdt, const Polygon_2 &polygon) static const struct v2d *find_point(const struct p2d *p, double x, double y) { - const struct v2d *v; + const struct v2d *v = p->v; - for (v = p->v; v; v = v->next) + while (v) { if (v->x == x && v->y == y) break; + v = v->next; + if (v == p->v) + return NULL; + } return v; }