]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: [_Hashtable] Add missing node destructor call
authorFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 6 Nov 2023 18:34:50 +0000 (19:34 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 7 Nov 2023 21:25:29 +0000 (22:25 +0100)
libstdc++-v3/ChangeLog:

* include/bits/hashtable_policy.h
(_Hashtable_alloc<>::_M_allocate_node): Add missing call to node destructor
on construct exception.

libstdc++-v3/include/bits/hashtable_policy.h

index 5d162463dc35152a14731f9d1b5c679c4a3841c2..a2731b3f63f4fab75127135b73b5660a17082420 100644 (file)
@@ -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;
          }
       }