Skip to content

Commit

Permalink
flat_buffer correctly handles consume()
Browse files Browse the repository at this point in the history
  • Loading branch information
cmazakas committed Jul 29, 2024
1 parent 86b2816 commit 1d6dd6b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/boost/buffers/flat_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class flat_buffer
std::size_t
capacity() const noexcept
{
return cap_ - in_pos_;
return cap_ - (in_pos_ + in_size_);
}

const_buffers_type
Expand All @@ -111,7 +111,7 @@ class flat_buffer
prepare(std::size_t n)
{
// n exceeds available space
if(n > cap_ - in_size_)
if( n > capacity() )
detail::throw_invalid_argument();

out_size_ = n;
Expand Down

0 comments on commit 1d6dd6b

Please sign in to comment.