From f02f5d07d19589e8db52b70c821c022da2261eb1 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 28 Apr 2021 17:53:41 +0100 Subject: [PATCH 1/3] Fix dereference after null in Triangulation_data_structure.h --- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index b3927cf03ae..1b14fbb03cd 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -1924,7 +1924,7 @@ create_star_2(Vertex_handle v, Cell_handle c, int li ) // pnew is null at the first iteration v1->set_cell(cnew); //pnew->set_neighbor( cw(pnew->index(v1)), cnew ); - if (pnew != Cell_handle()) { pnew->set_neighbor( 1, cnew );} + if (pnew != nullptr) { pnew->set_neighbor( 1, cnew );} bound = cur; i1 = ccw(i1); From 0dcadee4863b8885512dcd8708e859119ce6fc99 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 28 Apr 2021 17:54:19 +0100 Subject: [PATCH 2/3] Fix dereference after null in Polyhedron_incremental_builder_3.h --- .../CGAL/Polyhedron_incremental_builder_3.h | 14 +++++++------- STL_Extension/include/CGAL/In_place_list.h | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Polyhedron/include/CGAL/Polyhedron_incremental_builder_3.h b/Polyhedron/include/CGAL/Polyhedron_incremental_builder_3.h index f5686239a51..817646d79d2 100644 --- a/Polyhedron/include/CGAL/Polyhedron_incremental_builder_3.h +++ b/Polyhedron/include/CGAL/Polyhedron_incremental_builder_3.h @@ -402,7 +402,7 @@ protected: CGAL_assertion( ! last_vertex); HalfedgeDS_items_decorator decorator; Halfedge_handle e = get_vertex_to_edge_map( w); - if ( e != Halfedge_handle()) { + if ( e != nullptr) { CGAL_assertion( e->vertex() == index_to_vertex_map[w]); // check that the facet has no self intersections if ( current_face != Face_handle() @@ -491,7 +491,7 @@ protected: // Halfedge e points to a vertex w. Walk around w to find a hole // in the facet structure. Report an error if none exist. Return // the halfedge at this hole that points to the vertex w. - CGAL_assertion( e != Halfedge_handle()); + CGAL_assertion( e != nullptr); HalfedgeDS_items_decorator decorator; Halfedge_handle start_edge( e); do { @@ -649,7 +649,7 @@ add_vertex_to_facet( std::size_t v2) { Halfedge_handle hole = lookup_hole( v1); if ( m_error) return; - CGAL_assertion( hole != Halfedge_handle()); + CGAL_assertion( hole != nullptr); h2->opposite()->HBase::set_next( hole->next()); decorator.set_prev( hole->next(), h2->opposite()); hole->HBase::set_next( h1->opposite()); @@ -689,7 +689,7 @@ add_vertex_to_facet( std::size_t v2) { } while ( e->next() != prev && e != h1); if ( e == h1) { // disconnected facet complexes - if ( hole != Halfedge_handle()) { + if ( hole != nullptr) { // The complex can be connected with // the hole at hprime. hprime->HBase::set_next( hole->next()); @@ -763,8 +763,8 @@ test_facet_indices( std::vector< std::size_t> indices) { // check if halfedge is already in the HDS and is not border halfedge Halfedge_handle v = get_vertex_to_edge_map(indices[i]); Vertex_handle w = index_to_vertex_map[indices[i+1]]; - if ( v != Halfedge_handle() - && get_vertex_to_edge_map(indices[i+1]) != Halfedge_handle()) { + if ( v != nullptr + && get_vertex_to_edge_map(indices[i+1]) != nullptr) { // cycle through halfedge-loop and find edge to indices[i+1] Halfedge_handle vstart = v; do { @@ -780,7 +780,7 @@ test_facet_indices( std::vector< std::size_t> indices) { // tested for non-manifold halfedges already, we just need to check // if the vertex indices[i] is not a closed manifold yet. Halfedge_handle v = get_vertex_to_edge_map(indices[i]); - if ( v != Halfedge_handle()) { + if ( v != nullptr) { Halfedge_handle vstart = v; do { v = v->next()->opposite(); diff --git a/STL_Extension/include/CGAL/In_place_list.h b/STL_Extension/include/CGAL/In_place_list.h index e19c8ca5e4d..3266d1ae674 100644 --- a/STL_Extension/include/CGAL/In_place_list.h +++ b/STL_Extension/include/CGAL/In_place_list.h @@ -86,6 +86,8 @@ namespace internal { bool operator==( const Self& x) const { return node == x.node; } bool operator!=( const Self& x) const { return node != x.node; } + bool operator==( std::nullptr_t) const { return node == nullptr; } + bool operator!=( std::nullptr_t) const { return node != nullptr; } bool operator< ( const Self& x) const { return node< x.node; } bool operator<=( const Self& x) const { return node<= x.node; } bool operator> ( const Self& x) const { return node> x.node; } @@ -139,6 +141,8 @@ namespace internal { bool operator==( const Self& x) const { return node == x.node; } bool operator!=( const Self& x) const { return node != x.node; } + bool operator==( std::nullptr_t) const { return node == nullptr; } + bool operator!=( std::nullptr_t) const { return node != nullptr; } bool operator< ( const Self& x) const { return node< x.node; } bool operator<=( const Self& x) const { return node<= x.node; } bool operator> ( const Self& x) const { return node> x.node; } From b42bbded9beb82800d79f4d5eda74223ecc8ec59 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Wed, 5 May 2021 06:46:57 +0100 Subject: [PATCH 3/3] Add null comparison operators to vector_iterator --- STL_Extension/include/CGAL/vector.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/STL_Extension/include/CGAL/vector.h b/STL_Extension/include/CGAL/vector.h index e4c1a5bca28..c10a8fdd53a 100644 --- a/STL_Extension/include/CGAL/vector.h +++ b/STL_Extension/include/CGAL/vector.h @@ -109,6 +109,8 @@ public: tmp += n; return tmp.operator*(); } + bool operator==( std::nullptr_t) const { return ptr == nullptr; } + bool operator!=( std::nullptr_t) const { return ptr != nullptr; } bool operator< ( const Self& i) const { return ( ptr < i.ptr); } bool operator> ( const Self& i) const { return i < *this; } bool operator<=( const Self& i) const { return !(i < *this); }