From 4176a2a551eba3d81ccdc6ea2a923277955ce7f6 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 26 Sep 2025 12:09:13 +0100 Subject: [PATCH] Surface_mesh: Fix collect_garbage in case mesh is not valid --- .../include/CGAL/Surface_mesh/Surface_mesh.h | 11 +++++--- Surface_mesh/test/Surface_mesh/issue_9086.cpp | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Surface_mesh/test/Surface_mesh/issue_9086.cpp diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index d38d7ffeabd..ad339ef5ca7 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -2680,8 +2680,12 @@ collect_garbage(Visitor &visitor) for (i=0; i +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick; + +int main() +{ +CGAL::Surface_mesh mesh; + auto f0 = mesh.add_face(); + auto f1 = mesh.add_face(); // If this line is commented out, it will not crash. + mesh.remove_face(f0); + + auto v0 = mesh.add_vertex(); + auto v1 = mesh.add_vertex(); // If this line is commented out, it will not crash. + mesh.remove_vertex(v0); + + auto e0 = mesh.add_edge(); + auto e1 = mesh.add_edge(); // If this line is commented out, it will not crash. + mesh.remove_edge(edge(e0,mesh)); + + + mesh.collect_garbage(); + + return 0; +} \ No newline at end of file