From: Ville Voutilainen Date: Fri, 18 Dec 2015 21:27:53 +0000 (+0200) Subject: Fix a regression introduced by the fix of libstdc++/68276. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ca2c1b328327f998338cfa4b9e902e439cf57278;p=gcc.git Fix a regression introduced by the fix of libstdc++/68276. 2015-12-18 Ville Voutilainen Fix a regression introduced by the fix of libstdc++/68276. * src/c++11/ios.cc (_M_grow_words): Catch bad_alloc again so that bad_array_new_length is handled properly. From-SVN: r231839 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a37878d7867..c4f9f3c2e0a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2015-12-18 Ville Voutilainen + + Fix a regression introduced by the fix of libstdc++/68276. + * src/c++11/ios.cc (_M_grow_words): Catch bad_alloc again so that + bad_array_new_length is handled properly. + 2015-12-18 Ville Voutilainen PR libstdc++/68276 diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index f701e61f0d0..17dad559573 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -121,7 +121,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (__ix < numeric_limits::max()) { __newsize = __ix + 1; - __words = new (std::nothrow) _Words[__newsize]; + /* We still need to catch bad_alloc even though we use + a nothrow new, because the new-expression can throw + a bad_array_new_length. */ + __try + { __words = new (std::nothrow) _Words[__newsize]; } + __catch(const std::bad_alloc&) + { __words = nullptr; } if (!__words) { _M_streambuf_state |= badbit;