diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-14 09:51:32 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-14 09:51:32 +0000 |
commit | 4ce2c356262ecdf6995221433acb8449f871b202 (patch) | |
tree | 3fde7073366376d3c67f4d33fbc0f044357fdba6 /libstdc++-v3 | |
parent | 1a1b0255d7888eefbb84de3eda6ddd2a24610134 (diff) | |
download | gcc-4ce2c356262ecdf6995221433acb8449f871b202.tar.gz |
2006-10-14 Paolo Carlini <pcarlini@suse.de>
* include/bits/ostream.tcc (operator<<(basic_ostream<>&,
const char*)): Fix thinko in change for libstdc++/28277,
avoid memory leaks.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117729 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/ostream.tcc | 21 |
2 files changed, 22 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9df16614528..f286f680be4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2006-10-14 Paolo Carlini <pcarlini@suse.de> + + * include/bits/ostream.tcc (operator<<(basic_ostream<>&, + const char*)): Fix thinko in change for libstdc++/28277, + avoid memory leaks. + 2006-10-13 Paolo Carlini <pcarlini@suse.de> * include/bits/istream.tcc (operator>>(__istream_type& diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index 5bfde44dd3a..125e0fe4cb8 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -320,19 +320,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __out.setstate(ios_base::badbit); else { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 167. Improper use of traits_type::length() + const size_t __clen = char_traits<char>::length(__s); + _CharT* __ws = 0; + try + { __ws = new _CharT[__clen]; } + catch(...) + { + __out._M_setstate(ios_base::badbit); + return __out; + } + try { - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 167. Improper use of traits_type::length() - const size_t __clen = char_traits<char>::length(__s); - _CharT* __ws = new _CharT[__clen]; for (size_t __i = 0; __i < __clen; ++__i) __ws[__i] = __out.widen(__s[__i]); __out._M_insert(__ws, __clen); delete [] __ws; } catch(...) - { __out._M_setstate(ios_base::badbit); } + { + delete [] __ws; + __throw_exception_again; + } } return __out; } |