diff options
Diffstat (limited to 'contrib/libstdc++/include/bits/streambuf.tcc')
| -rw-r--r-- | contrib/libstdc++/include/bits/streambuf.tcc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/contrib/libstdc++/include/bits/streambuf.tcc b/contrib/libstdc++/include/bits/streambuf.tcc index c8084ee68ada..5f57df583a7b 100644 --- a/contrib/libstdc++/include/bits/streambuf.tcc +++ b/contrib/libstdc++/include/bits/streambuf.tcc @@ -69,7 +69,7 @@ namespace std bool __testpos = _M_in_cur && _M_in_beg < _M_in_cur; bool __testne = _M_in_cur && !traits_type::eq(__c, this->gptr()[-1]); if (!__testpos || __testne) - __ret = pbackfail(traits_type::to_int_type(__c)); + __ret = this->pbackfail(traits_type::to_int_type(__c)); else { _M_in_cur_move(-1); @@ -209,7 +209,8 @@ namespace std { while (__testput && __bufsize != -1) { - if (__bufsize != 0 && __sbin->gptr() != NULL) + if (__bufsize != 0 && __sbin->gptr() != NULL + && __sbin->gptr() + __bufsize <= __sbin->egptr()) { __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize); __ret += __xtrct; @@ -219,8 +220,11 @@ namespace std } else { - _CharT __buf[256]; - streamsize __charsread = __sbin->sgetn(__buf, sizeof(__buf)); + size_t __size = + __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1; + _CharT* __buf = + static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __size)); + streamsize __charsread = __sbin->sgetn(__buf, __size); __xtrct = __sbout->sputn(__buf, __charsread); __ret += __xtrct; if (__xtrct != __charsread) |
