File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
include/bitcoin/system/impl/stream/streamers Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -655,8 +655,11 @@ byte_allocator& byte_reader<IStream>::get_allocator() const NOEXCEPT
655
655
template <typename IStream>
656
656
uint8_t byte_reader<IStream>::do_peek_byte() NOEXCEPT
657
657
{
658
- if (limiter (one))
658
+ if (is_zero (remaining_))
659
+ {
660
+ invalid ();
659
661
return pad ();
662
+ }
660
663
661
664
// This sets eofbit (or badbit) on empty and eofbit if otherwise at end.
662
665
// eofbit does not cause !!eofbit == true, but badbit does, so we validate
Original file line number Diff line number Diff line change @@ -467,6 +467,11 @@ BOOST_AUTO_TEST_CASE(byte_reader__set_limit__set_position_forward_peek__limited)
467
467
reader.set_position (3 );
468
468
BOOST_REQUIRE (!reader.is_exhausted ());
469
469
470
+ // Peek does not consume limit (as verified by subsequent reads).
471
+ BOOST_REQUIRE_EQUAL (reader.peek_byte (), ' d' );
472
+ BOOST_REQUIRE_EQUAL (reader.peek_byte (), ' d' );
473
+ BOOST_REQUIRE_EQUAL (reader.peek_byte (), ' d' );
474
+
470
475
// Read to limit and verify.
471
476
BOOST_REQUIRE_EQUAL (reader.get_read_position (), 3u );
472
477
BOOST_REQUIRE_EQUAL (reader.read_byte (), ' d' );
You can’t perform that action at this time.
0 commit comments