public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Francois Dumont <fdumont@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r14-5230] libstdc++: [_Hashtable] Add missing node destructor call
Date: Tue,  7 Nov 2023 21:26:55 +0000 (GMT)	[thread overview]
Message-ID: <20231107212655.3FB5D3858433@sourceware.org> (raw)

https://gcc.gnu.org/g:8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84

commit r14-5230-g8f2a59c2629f634e0ea7b2bcc4443fd57c2a0e84
Author: François Dumont <fdumont@gcc.gnu.org>
Date:   Mon Nov 6 19:34:50 2023 +0100

    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.

Diff:
---
 libstdc++-v3/include/bits/hashtable_policy.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 5d162463dc3..a2731b3f63f 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;
 	  }
       }

                 reply	other threads:[~2023-11-07 21:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231107212655.3FB5D3858433@sourceware.org \
    --to=fdumont@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).