From: ville Date: Fri, 18 Dec 2015 21:27:53 +0000 (+0000) Subject: 2015-12-18 Ville Voutilainen X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3de9f2d157bf43cedf266240c3581f364e41e5a;p=thirdparty%2Fgcc.git 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231839 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a37878d78670..c4f9f3c2e0a3 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 f701e61f0d0c..17dad5595733 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;