diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2006-07-15 20:30:50 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2006-07-15 20:30:50 +0000 |
commit | 6f0cb138018a2665e6fff1067ba5a29a98ec8c0c (patch) | |
tree | 65ba10596ac222fd1caa9cee446e3f94d5b4755e /libstdc++-v3/include/bits/ostream.tcc | |
parent | b0d5d5de789ef8cb4df99c08c3bf864152e65e75 (diff) | |
download | gcc-6f0cb138018a2665e6fff1067ba5a29a98ec8c0c.zip gcc-6f0cb138018a2665e6fff1067ba5a29a98ec8c0c.tar.gz gcc-6f0cb138018a2665e6fff1067ba5a29a98ec8c0c.tar.bz2 |
PR libstdc++/28277 (partial: ostream bits 1)
2006-07-15 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/28277 (partial: ostream bits 1)
* include/bits/ostream.tcc (operator<<(basic_ostream<_CharT>&,
const char*)): Avoid __builtin_alloca with no limit in the
widening.
* testsuite/27_io/basic_ostream/inserters_character/wchar_t/
28277-1.cc: New.
From-SVN: r115485
Diffstat (limited to 'libstdc++-v3/include/bits/ostream.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/ostream.tcc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index 7f9fbcf..d53cd07 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -421,15 +421,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typename __ostream_type::sentry __cerb(__out); if (__cerb && __s) { - size_t __clen = __traits_type::length(__s); - _CharT* __ws = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) - * __clen)); - for (size_t __i = 0; __i < __clen; ++__i) - __ws[__i] = __out.widen(__s[__i]); - _CharT* __str = __ws; - + _CharT* __ws = 0; try { + const size_t __clen = __traits_type::length(__s); + __ws = new _CharT[__clen]; + for (size_t __i = 0; __i < __clen; ++__i) + __ws[__i] = __out.widen(__s[__i]); + _CharT* __str = __ws; + const streamsize __w = __out.width(); streamsize __len = static_cast<streamsize>(__clen); if (__w > __len) @@ -444,9 +444,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } __out._M_write(__str, __len); __out.width(0); + + delete [] __ws; } catch(...) - { __out._M_setstate(ios_base::badbit); } + { + delete [] __ws; + __out._M_setstate(ios_base::badbit); + } } else if (!__s) __out.setstate(ios_base::badbit); |