diff --git a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h index e17851e096a..8417e20b226 100644 --- a/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h +++ b/Linear_cell_complex/include/CGAL/CMap_linear_cell_complex_storages_with_index.h @@ -309,6 +309,13 @@ namespace CGAL { { CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "copy_attribute called but i-attributes are disabled."); + // We need to do a reserve before the emplace in order to avoid a bug of + // invalid reference when the container is reallocated. + std::get::value> + (mattribute_containers).reserve + (std::get::value> + (mattribute_containers).size()+1); + typename Attribute_descriptor::type res= std::get::value> (mattribute_containers).emplace(get_attribute(ah)); diff --git a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h index a2a58088828..27d58a7651a 100644 --- a/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h +++ b/Linear_cell_complex/include/CGAL/GMap_linear_cell_complex_storages_with_index.h @@ -261,6 +261,13 @@ namespace CGAL { { CGAL_static_assertion_msg(Helper::template Dimension_index::value>=0, "copy_attribute called but i-attributes are disabled."); + // We need to do a reserve before the emplace in order to avoid a bug of + // invalid reference when the container is reallocated. + std::get::value> + (mattribute_containers).reserve + (std::get::value> + (mattribute_containers).size()+1); + typename Attribute_descriptor::type res= std::get::value> (mattribute_containers).emplace(get_attribute(ah));