This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Avoid leak in _Rb_tree<>::_M_insert
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 27 Feb 2005 00:39:41 +0100
- Subject: [v3] Avoid leak in _Rb_tree<>::_M_insert
Hi,
tested x86-linux, committed to mainline.
Paolo.
///////////
2005-02-26 Earl Chew <earl_chew@agilent.com>
Christopher Jefferson <chris@bubblescope.net>
* include/bits/stl_tree.h (_Rb_tree<>::_M_insert): Don't leak
memory if _M_key_compare throws.
diff -prN libstdc++-v3-orig/include/bits/stl_tree.h libstdc++-v3/include/bits/stl_tree.h
*** libstdc++-v3-orig/include/bits/stl_tree.h Tue Feb 1 14:30:30 2005
--- libstdc++-v3/include/bits/stl_tree.h Sat Feb 26 23:56:43 2005
*************** namespace std
*** 786,797 ****
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
_M_insert(_Base_ptr __x, _Base_ptr __p, const _Val& __v)
{
! _Link_type __z = _M_create_node(__v);
! bool __insert_left;
! __insert_left = (__x != 0 || __p == _M_end()
! || _M_impl._M_key_compare(_KeyOfValue()(__v),
! _S_key(__p)));
_Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
this->_M_impl._M_header);
--- 786,796 ----
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
_M_insert(_Base_ptr __x, _Base_ptr __p, const _Val& __v)
{
! bool __insert_left = (__x != 0 || __p == _M_end()
! || _M_impl._M_key_compare(_KeyOfValue()(__v),
! _S_key(__p)));
! _Link_type __z = _M_create_node(__v);
_Rb_tree_insert_and_rebalance(__insert_left, __z, __p,
this->_M_impl._M_header);