From 360040dfd626e03fa89eb8b8ab5f0f1f1183fbc0 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 14 Dec 2020 15:10:30 +0100 Subject: [PATCH 1/2] Fix ptrdiff_t overflow --- .../CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h index 04b53b6c7af..6afb0949552 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h @@ -623,10 +623,11 @@ namespace CGAL { const std::ptrdiff_t n, FT &low, FT &high) { - const FT q = FT(x * n * double(UN - x) * (UN - n) / (UN - 1)); + const FT xn = double(x) * double(n); + const FT q = FT(xn * double(UN - x) * (UN - n) / (UN - 1)); const FT sq = CGAL::sqrt(q); - low = (x * n - sq) / UN; - high = (x * n + sq)/UN; + low = (xn - sq) / UN; + high = (xn + sq)/UN; if (!is_finite(low) || !is_finite(high)) { low = high = 0; From a7b2ed13f4623103f21c820ec4d23e316f903d1a Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 15 Dec 2020 15:44:11 +0100 Subject: [PATCH 2/2] Fix conversion warning --- .../include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h index 6afb0949552..21d21d13dab 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h +++ b/Shape_detection/include/CGAL/Shape_detection/Efficient_RANSAC/Shape_base.h @@ -623,7 +623,7 @@ namespace CGAL { const std::ptrdiff_t n, FT &low, FT &high) { - const FT xn = double(x) * double(n); + const FT xn = FT(double(x) * double(n)); const FT q = FT(xn * double(UN - x) * (UN - n) / (UN - 1)); const FT sq = CGAL::sqrt(q); low = (xn - sq) / UN;