1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

bytevector: fix length check

ByteVectors, and shared subranges thereof, might be empty.  The parameter
check should allow that.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2022-10-10 17:33:40 -04:00
parent 14ce81c081
commit 587588d53f

View File

@ -45,8 +45,8 @@ namespace crucible {
ByteVector::ByteVector(const ByteVector &that, size_t start, size_t length) ByteVector::ByteVector(const ByteVector &that, size_t start, size_t length)
{ {
THROW_CHECK0(out_of_range, that.m_ptr); THROW_CHECK0(out_of_range, that.m_ptr);
THROW_CHECK2(out_of_range, start, that.m_size, start < that.m_size); THROW_CHECK2(out_of_range, start, that.m_size, start <= that.m_size);
THROW_CHECK2(out_of_range, start + length, that.m_size + length, start + length < that.m_size + length); THROW_CHECK2(out_of_range, start + length, that.m_size + length, start + length <= that.m_size + length);
m_ptr = Pointer(that.m_ptr, that.m_ptr.get() + start); m_ptr = Pointer(that.m_ptr, that.m_ptr.get() + start);
m_size = length; m_size = length;
} }