From 8584915d3e630efc502ca7e90094a2eb814fda2d Mon Sep 17 00:00:00 2001 From: Liss Heidrich <31625940+liss-h@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:45:35 +0100 Subject: [PATCH] fix --- include/dice/sparse-map/sparse_hash.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/dice/sparse-map/sparse_hash.hpp b/include/dice/sparse-map/sparse_hash.hpp index 670e953..91c258e 100644 --- a/include/dice/sparse-map/sparse_hash.hpp +++ b/include/dice/sparse-map/sparse_hash.hpp @@ -762,10 +762,16 @@ class sparse_array { static void destroy_and_deallocate_values( allocator_type &alloc, pointer values, size_type nb_values, size_type capacity_values) noexcept { + if (capacity_values == 0) { + tsl_sh_assert(nb_values == 0); + // nothing to deallocate + // alloc.deallocate(nullptr, 0) is invalid + return; + } + for (size_type i = 0; i < nb_values; i++) { destroy_value(alloc, values + i); } - alloc.deallocate(values, capacity_values); }