diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2022-10-12 17:07:15 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-11-13 18:51:18 -0700 |
commit | db40a514f5c2624c546c1430b3da276ec4d5d5cd (patch) | |
tree | d81f3c5d9e5aeec38358131129ffbe13c4cc702f /Userland/Libraries | |
parent | 706638a0d0e1a8ca0733ca0c07fd3037885dc62b (diff) | |
download | serenity-db40a514f5c2624c546c1430b3da276ec4d5d5cd.zip |
LibCore: Allow `MemoryStream::seek` to go to EOF
The method still prevents you to go out of bound.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibCore/MemoryStream.h | 6 |
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; |