From 587588d53f6f23ec0c7a7a84063626395a8348e7 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 10 Oct 2022 17:33:40 -0400 Subject: [PATCH] bytevector: fix length check ByteVectors, and shared subranges thereof, might be empty. The parameter check should allow that. Signed-off-by: Zygo Blaxell --- lib/bytevector.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bytevector.cc b/lib/bytevector.cc index 083aa8e..a4482f2 100644 --- a/lib/bytevector.cc +++ b/lib/bytevector.cc @@ -45,8 +45,8 @@ namespace crucible { ByteVector::ByteVector(const ByteVector &that, size_t start, size_t length) { 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 + length, that.m_size + length, start + length < that.m_size + length); + 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); m_ptr = Pointer(that.m_ptr, that.m_ptr.get() + start); m_size = length; }