summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-10-12 17:07:15 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-11-13 18:51:18 -0700
commitdb40a514f5c2624c546c1430b3da276ec4d5d5cd (patch)
treed81f3c5d9e5aeec38358131129ffbe13c4cc702f /Userland
parent706638a0d0e1a8ca0733ca0c07fd3037885dc62b (diff)
downloadserenity-db40a514f5c2624c546c1430b3da276ec4d5d5cd.zip
LibCore: Allow `MemoryStream::seek` to go to EOF
The method still prevents you to go out of bound.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/MemoryStream.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCore/MemoryStream.h b/Userland/Libraries/LibCore/MemoryStream.h
index e46ed0da0c..569eb307db 100644
--- a/Userland/Libraries/LibCore/MemoryStream.h
+++ b/Userland/Libraries/LibCore/MemoryStream.h
@@ -44,19 +44,19 @@ public:
{
switch (seek_mode) {
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");
m_offset = offset;
break;
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");
m_offset += offset;
break;
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");
m_offset = m_bytes.size() - offset;