From 4fb1953207c64de93583e332e0af475bfdb46b98 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 14 Oct 2006 10:25:35 +0000 Subject: [PATCH] ostream.tcc (operator<<(basic_ostream<>&, const char*)): Further fix for throwing widen. 2006-10-14 Paolo Carlini * include/bits/ostream.tcc (operator<<(basic_ostream<>&, const char*)): Further fix for throwing widen. From-SVN: r117730 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/ostream.tcc | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f286f68..0609457 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,11 @@ 2006-10-14 Paolo Carlini * include/bits/ostream.tcc (operator<<(basic_ostream<>&, + const char*)): Further fix for throwing widen. + +2006-10-14 Paolo Carlini + + * include/bits/ostream.tcc (operator<<(basic_ostream<>&, const char*)): Fix thinko in change for libstdc++/28277, avoid memory leaks. diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index 125e0fe..db09d0a 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -325,17 +325,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const size_t __clen = char_traits::length(__s); _CharT* __ws = 0; try - { __ws = new _CharT[__clen]; } + { + __ws = new _CharT[__clen]; + for (size_t __i = 0; __i < __clen; ++__i) + __ws[__i] = __out.widen(__s[__i]); + } catch(...) { + delete [] __ws; __out._M_setstate(ios_base::badbit); return __out; } try { - for (size_t __i = 0; __i < __clen; ++__i) - __ws[__i] = __out.widen(__s[__i]); __out._M_insert(__ws, __clen); delete [] __ws; } -- 2.7.4