mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:57:47 +00:00
LibCore: Allow MemoryStream::seek
to go to EOF
The method still prevents you to go out of bound.
This commit is contained in:
parent
706638a0d0
commit
db40a514f5
1 changed files with 3 additions and 3 deletions
|
@ -44,19 +44,19 @@ public:
|
||||||
{
|
{
|
||||||
switch (seek_mode) {
|
switch (seek_mode) {
|
||||||
case SeekMode::SetPosition:
|
case SeekMode::SetPosition:
|
||||||
if (offset >= static_cast<i64>(m_bytes.size()))
|
if (offset > static_cast<i64>(m_bytes.size()))
|
||||||
return Error::from_string_literal("Offset past the end of the stream memory");
|
return Error::from_string_literal("Offset past the end of the stream memory");
|
||||||
|
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
break;
|
break;
|
||||||
case SeekMode::FromCurrentPosition:
|
case SeekMode::FromCurrentPosition:
|
||||||
if (offset + static_cast<i64>(m_offset) >= static_cast<i64>(m_bytes.size()))
|
if (offset + static_cast<i64>(m_offset) > static_cast<i64>(m_bytes.size()))
|
||||||
return Error::from_string_literal("Offset past the end of the stream memory");
|
return Error::from_string_literal("Offset past the end of the stream memory");
|
||||||
|
|
||||||
m_offset += offset;
|
m_offset += offset;
|
||||||
break;
|
break;
|
||||||
case SeekMode::FromEndPosition:
|
case SeekMode::FromEndPosition:
|
||||||
if (offset >= static_cast<i64>(m_bytes.size()))
|
if (offset > static_cast<i64>(m_bytes.size()))
|
||||||
return Error::from_string_literal("Offset past the start of the stream memory");
|
return Error::from_string_literal("Offset past the start of the stream memory");
|
||||||
|
|
||||||
m_offset = m_bytes.size() - offset;
|
m_offset = m_bytes.size() - offset;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue