From 25e3b4239c542a519b8e0b05eb0e7ac27cf4d75b Mon Sep 17 00:00:00 2001 From: Eidolon Date: Tue, 3 Jan 2023 19:24:48 -0600 Subject: [PATCH] io: Allow span and vec stream to seek past end --- src/io/streams.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/io/streams.hpp b/src/io/streams.hpp index ca4d7cda8..643cfd987 100644 --- a/src/io/streams.hpp +++ b/src/io/streams.hpp @@ -418,7 +418,7 @@ public: switch (seek_from) { case SeekFrom::kStart: - if (offset < 0 || offset >= static_cast(span_.size())) { + if (offset < 0) { throw std::logic_error("start offset is out of bounds"); } head = offset; @@ -430,7 +430,7 @@ public: head = span_.size() - offset; break; case SeekFrom::kCurrent: - if (head_ + offset < 0 || head_ + offset >= span_.size()) { + if (head_ + offset < 0) { throw std::logic_error("offset is out of bounds"); } head = head_ + offset; @@ -489,7 +489,7 @@ public: switch (seek_from) { case SeekFrom::kStart: - if (offset < 0 || offset >= static_cast(vec_.size())) { + if (offset < 0) { throw std::logic_error("start offset is out of bounds"); } head = offset; @@ -501,7 +501,7 @@ public: head = vec_.size() - offset; break; case SeekFrom::kCurrent: - if (head_ + offset < 0 || head_ + offset >= vec_.size()) { + if (head_ + offset < 0) { throw std::logic_error("offset is out of bounds"); } head = head_ + offset;