Commit ca2c1b32 by Ville Voutilainen Committed by Ville Voutilainen

Fix a regression introduced by the fix of libstdc++/68276.

2015-12-18  Ville Voutilainen  <ville.voutilainen@gmail.com>

	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
parent e8f47b66
2015-12-18 Ville Voutilainen <ville.voutilainen@gmail.com> 2015-12-18 Ville Voutilainen <ville.voutilainen@gmail.com>
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 <ville.voutilainen@gmail.com>
PR libstdc++/68276 PR libstdc++/68276
* src/c++11/ios.cc (_M_grow_words): Use nothrow new. * src/c++11/ios.cc (_M_grow_words): Use nothrow new.
......
...@@ -121,7 +121,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -121,7 +121,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__ix < numeric_limits<int>::max()) if (__ix < numeric_limits<int>::max())
{ {
__newsize = __ix + 1; __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) if (!__words)
{ {
_M_streambuf_state |= badbit; _M_streambuf_state |= badbit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment