File tree Expand file tree Collapse file tree
include/bitcoin/system/impl/stream/iostream Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ namespace system {
2828
2929// Allowed here for low level performance benefit.
3030BC_PUSH_WARNING (NO_POINTER_ARITHMETIC)
31+ BC_PUSH_WARNING (NO_UNSAFE_COPY_N)
3132
3233template <typename Character>
3334template <typename Buffer>
@@ -150,18 +151,19 @@ template <typename Character>
150151void
151152istream<Character>::read(char_type* data, std::streamsize count) NOEXCEPT
152153{
153- const auto bytes = possible_narrow_sign_cast<size_t >(count);
154+ auto bytes = possible_narrow_sign_cast<size_t >(count);
154155
155156 if (is_overflow (bytes))
156157 {
158+ if (state_ != goodbit)
159+ return ;
160+
161+ // Allow read to end if state was good (std::istream behavior).
162+ bytes = end_ - position_;
157163 setstate (badbit);
158- return ;
159164 }
160165
161- BC_PUSH_WARNING (NO_UNSAFE_COPY_N)
162166 std::copy_n (position_, bytes, data);
163- BC_POP_WARNING ()
164-
165167 position_ += bytes;
166168}
167169
@@ -181,6 +183,7 @@ istream<Character>::is_overflow(pos_type size) const NOEXCEPT
181183 return (state_ != goodbit) || (size > (end_ - position_));
182184}
183185
186+ BC_POP_WARNING ()
184187BC_POP_WARNING ()
185188
186189} // namespace system
You can’t perform that action at this time.
0 commit comments