From ca2c1b328327f998338cfa4b9e902e439cf57278 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Fri, 18 Dec 2015 23:27:53 +0200 Subject: [PATCH] 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 --- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/src/c++11/ios.cc | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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; -- 2.30.2