diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2023-11-06 19:34:50 +0100 |
---|---|---|
committer | François Dumont <fdumont@gcc.gnu.org> | 2023-11-07 22:25:29 +0100 |
commit | 8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84 (patch) | |
tree | 589a36290f917510f9426ae4732c0240743ed9dc | |
parent | d90e5ece367be4648398faabfc06e9c9c0111df1 (diff) | |
download | gcc-8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84.zip gcc-8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84.tar.gz gcc-8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84.tar.bz2 |
libstdc++: [_Hashtable] Add missing node destructor call
libstdc++-v3/ChangeLog:
* include/bits/hashtable_policy.h
(_Hashtable_alloc<>::_M_allocate_node): Add missing call to node destructor
on construct exception.
-rw-r--r-- | libstdc++-v3/include/bits/hashtable_policy.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 5d16246..a2731b3 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1990,19 +1990,20 @@ namespace __detail _Hashtable_alloc<_NodeAlloc>::_M_allocate_node(_Args&&... __args) -> __node_ptr { - auto __nptr = __node_alloc_traits::allocate(_M_node_allocator(), 1); + auto& __alloc = _M_node_allocator(); + auto __nptr = __node_alloc_traits::allocate(__alloc, 1); __node_ptr __n = std::__to_address(__nptr); __try { ::new ((void*)__n) __node_type; - __node_alloc_traits::construct(_M_node_allocator(), - __n->_M_valptr(), + __node_alloc_traits::construct(__alloc, __n->_M_valptr(), std::forward<_Args>(__args)...); return __n; } __catch(...) { - __node_alloc_traits::deallocate(_M_node_allocator(), __nptr, 1); + __n->~__node_type(); + __node_alloc_traits::deallocate(__alloc, __nptr, 1); __throw_exception_again; } } |