From b080804f09d78cc462e1e0a611a6a3d5ae20e2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 13 Mar 2018 11:14:06 +0100 Subject: [PATCH] Fixed missing bound check in the sequential insertion phase If the input point set is degenerate, dimension() < 3 is always 'true' and we will eventually try to read beyond the end of the points vector. See issue https://github.com/CGAL/cgal/issues/2922 --- Triangulation_3/include/CGAL/Delaunay_triangulation_3.h | 4 ++-- Triangulation_3/include/CGAL/Regular_triangulation_3.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h index 3f18c2f5e57..01d8930fa03 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_3.h @@ -381,7 +381,7 @@ public: // Insert "num_points_seq" points sequentially // (or more if dim < 3 after that) size_t num_points_seq = (std::min)(num_points, (size_t)100); - while (dimension() < 3 || i < num_points_seq) + while (i < num_points_seq || (dimension() < 3 && i < num_points)) { hint = insert(points[i], hint); ++i; @@ -464,7 +464,7 @@ private: // Insert "num_points_seq" points sequentially // (or more if dim < 3 after that) size_t num_points_seq = (std::min)(num_points, (size_t)100); - while (dimension() < 3 || i < num_points_seq) + while (i < num_points_seq || (dimension() < 3 && i < num_points)) { hint = insert(points[indices[i]], hint); if (hint != Vertex_handle()) hint->info() = infos[indices[i]]; diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 7287944d586..bdb6d561bba 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -360,7 +360,7 @@ namespace CGAL { // Insert "num_points_seq" points sequentially // (or more if dim < 3 after that) size_t num_points_seq = (std::min)(num_points, (size_t)100); - while (dimension() < 3 || i < num_points_seq) + while (i < num_points_seq || (dimension() < 3 && i < num_points)) { Locate_type lt; Cell_handle c; @@ -483,7 +483,7 @@ namespace CGAL { // Insert "num_points_seq" points sequentially // (or more if dim < 3 after that) size_t num_points_seq = (std::min)(num_points, (size_t)100); - while (dimension() < 3 || i < num_points_seq) + while (i < num_points_seq || (dimension() < 3 && i < num_points)) { Locate_type lt; Cell_handle c;