io: Allow span and vec stream to seek past end

This commit is contained in:
Eidolon 2023-01-03 19:24:48 -06:00
parent 2a0e183340
commit 25e3b4239c

View file

@ -418,7 +418,7 @@ public:
switch (seek_from) { switch (seek_from) {
case SeekFrom::kStart: case SeekFrom::kStart:
if (offset < 0 || offset >= static_cast<StreamOffset>(span_.size())) { if (offset < 0) {
throw std::logic_error("start offset is out of bounds"); throw std::logic_error("start offset is out of bounds");
} }
head = offset; head = offset;
@ -430,7 +430,7 @@ public:
head = span_.size() - offset; head = span_.size() - offset;
break; break;
case SeekFrom::kCurrent: case SeekFrom::kCurrent:
if (head_ + offset < 0 || head_ + offset >= span_.size()) { if (head_ + offset < 0) {
throw std::logic_error("offset is out of bounds"); throw std::logic_error("offset is out of bounds");
} }
head = head_ + offset; head = head_ + offset;
@ -489,7 +489,7 @@ public:
switch (seek_from) { switch (seek_from) {
case SeekFrom::kStart: case SeekFrom::kStart:
if (offset < 0 || offset >= static_cast<StreamOffset>(vec_.size())) { if (offset < 0) {
throw std::logic_error("start offset is out of bounds"); throw std::logic_error("start offset is out of bounds");
} }
head = offset; head = offset;
@ -501,7 +501,7 @@ public:
head = vec_.size() - offset; head = vec_.size() - offset;
break; break;
case SeekFrom::kCurrent: case SeekFrom::kCurrent:
if (head_ + offset < 0 || head_ + offset >= vec_.size()) { if (head_ + offset < 0) {
throw std::logic_error("offset is out of bounds"); throw std::logic_error("offset is out of bounds");
} }
head = head_ + offset; head = head_ + offset;