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
This commit is contained in:
Mael Rouxel-Labbé 2018-03-13 11:14:06 +01:00
parent 29747165f7
commit b080804f09
2 changed files with 4 additions and 4 deletions

View File

@ -381,7 +381,7 @@ public:
// Insert "num_points_seq" points sequentially // Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that) // (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100); 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); hint = insert(points[i], hint);
++i; ++i;
@ -464,7 +464,7 @@ private:
// Insert "num_points_seq" points sequentially // Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that) // (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100); 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); hint = insert(points[indices[i]], hint);
if (hint != Vertex_handle()) hint->info() = infos[indices[i]]; if (hint != Vertex_handle()) hint->info() = infos[indices[i]];

View File

@ -360,7 +360,7 @@ namespace CGAL {
// Insert "num_points_seq" points sequentially // Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that) // (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100); 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; Locate_type lt;
Cell_handle c; Cell_handle c;
@ -483,7 +483,7 @@ namespace CGAL {
// Insert "num_points_seq" points sequentially // Insert "num_points_seq" points sequentially
// (or more if dim < 3 after that) // (or more if dim < 3 after that)
size_t num_points_seq = (std::min)(num_points, (size_t)100); 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; Locate_type lt;
Cell_handle c; Cell_handle c;