From 3951c38637df580ec3652f999294554acc434809 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 4 May 2020 18:54:19 +0200 Subject: [PATCH 1/5] Fix UBSAN error: do not bind reference to null pointer Equivalent to #4683 --- Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h | 10 +++++----- TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 0a055ddbb72..4df69ac5252 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -408,7 +408,7 @@ class Compact_mesh_cell_base_3 void set_neighbor(int i, Cell_handle n) { CGAL_triangulation_precondition( i >= 0 && i <= 3); - CGAL_triangulation_precondition( this != &*n ); + CGAL_triangulation_precondition( this != n.operator->() ); N[i] = n; } @@ -421,10 +421,10 @@ class Compact_mesh_cell_base_3 void set_neighbors(Cell_handle n0, Cell_handle n1, Cell_handle n2, Cell_handle n3) { - CGAL_triangulation_precondition( this != &*n0 ); - CGAL_triangulation_precondition( this != &*n1 ); - CGAL_triangulation_precondition( this != &*n2 ); - CGAL_triangulation_precondition( this != &*n3 ); + CGAL_triangulation_precondition( this != n0.operator->() ); + CGAL_triangulation_precondition( this != n1.operator->() ); + CGAL_triangulation_precondition( this != n2.operator->() ); + CGAL_triangulation_precondition( this != n3.operator->() ); N[0] = n0; N[1] = n1; N[2] = n2; diff --git a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h index 423b072f9bf..664fb53b5b2 100644 --- a/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h +++ b/TDS_3/include/CGAL/Triangulation_ds_cell_base_3.h @@ -190,10 +190,10 @@ class Triangulation_ds_cell_base_3 void set_neighbors(Cell_handle n0, Cell_handle n1, Cell_handle n2, Cell_handle n3) { - CGAL_triangulation_precondition( this != &*n0 ); - CGAL_triangulation_precondition( this != &*n1 ); - CGAL_triangulation_precondition( this != &*n2 ); - CGAL_triangulation_precondition( this != &*n3 ); + CGAL_triangulation_precondition( this != n0.operator->() ); + CGAL_triangulation_precondition( this != n1.operator->() ); + CGAL_triangulation_precondition( this != n2.operator->() ); + CGAL_triangulation_precondition( this != n3.operator->() ); N[0] = n0; N[1] = n1; N[2] = n2; From 5988befc687ec6d0e93c65c93750e9f4577f104c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 5 May 2020 10:02:32 +0200 Subject: [PATCH 2/5] Fix remaining std::max --- .../Plugins/Classification/Cluster_classification.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp index 3f77fe4efff..0a4c06f9feb 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Cluster_classification.cpp @@ -527,7 +527,7 @@ void Cluster_classification::change_color (int index, float* vmin, float* vmax) int cid = m_cluster_id[*it]; if (cid != -1) { - float v = std::max (0.f, (std::min)(1.f, m_label_probabilities[corrected_index][cid])); + float v = (std::max) (0.f, (std::min)(1.f, m_label_probabilities[corrected_index][cid])); m_points->point_set()->set_color(*it, ramp.r(v) * 255, ramp.g(v) * 255, ramp.b(v) * 255); } else From 098cc6abde450a46061723a56c0f745692808294 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 6 May 2020 11:31:13 +0200 Subject: [PATCH 3/5] Fix a PMP example --- .../Polygon_mesh_processing/repair_polygon_soup_example.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/repair_polygon_soup_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/repair_polygon_soup_example.cpp index e44be56106e..4d9003f0d6a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/repair_polygon_soup_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/repair_polygon_soup_example.cpp @@ -11,7 +11,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; -typedef std::vector Polygon; +typedef std::vector CGAL_Polygon; typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -20,7 +20,7 @@ int main(int, char**) { // First, construct a polygon soup with some problems std::vector points; - std::vector polygons; + std::vector polygons; points.push_back(Point_3(0,0,0)); points.push_back(Point_3(1,0,0)); @@ -30,7 +30,7 @@ int main(int, char**) points.push_back(Point_3(0,1,0)); // duplicate point points.push_back(Point_3(0,-2,0)); // unused point - Polygon p; + CGAL_Polygon p; p.push_back(0); p.push_back(1); p.push_back(2); polygons.push_back(p); From e3f2660b048263dc37074e6a7b2ee1f382e5af11 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 6 May 2020 11:33:27 +0200 Subject: [PATCH 4/5] Fix an item in the demo --- .../Plugins/Classification/Surface_mesh_item_classification.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp index 1d033c02fdb..f726fe42cf4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Classification/Surface_mesh_item_classification.cpp @@ -151,7 +151,7 @@ void Surface_mesh_item_classification::change_color (int index, float* vmin, flo { BOOST_FOREACH(face_descriptor fd, faces(*(m_mesh->polyhedron()))) { - float v = std::max (0.f, (std::min)(1.f, m_label_probabilities[corrected_index][fd])); + float v = (std::max) (0.f, (std::min)(1.f, m_label_probabilities[corrected_index][fd])); m_color[fd] = CGAL::Color((unsigned char)(ramp.r(v) * 255), (unsigned char)(ramp.g(v) * 255), (unsigned char)(ramp.b(v) * 255)); From e6b1e5531c876cb252158a81efc2dabec8794de4 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 7 May 2020 09:49:53 +0200 Subject: [PATCH 5/5] Fix affine_transformation_plugin --- .../Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp index d65db7c9dd9..d9c7425b3a2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PCA/Affine_transform_plugin.cpp @@ -133,11 +133,11 @@ class Scene_transform_point_set_item : public Scene_item { bbox = bbox + ps.point(*it).bbox(); } - CGAL::qglviewer::Vec min(bbox.xmin(),bbox.ymin(),bbox.zmin()); - CGAL::qglviewer::Vec max(bbox.xmax(),bbox.ymax(),bbox.zmax()); + CGAL::qglviewer::Vec v_min(bbox.xmin(),bbox.ymin(),bbox.zmin()); + CGAL::qglviewer::Vec v_max(bbox.xmax(),bbox.ymax(),bbox.zmax()); - _bbox = Bbox(min.x,min.y,min.z, - max.x,max.y,max.z); + _bbox = Bbox(v_min.x,v_min.y,v_min.z, + v_max.x,v_max.y,v_max.z); } bool isEmpty() const{return false;} Q_SIGNALS: