From db40a514f5c2624c546c1430b3da276ec4d5d5cd Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Wed, 12 Oct 2022 17:07:15 +0200 Subject: [PATCH] LibCore: Allow `MemoryStream::seek` to go to EOF The method still prevents you to go out of bound. --- Userland/Libraries/LibCore/MemoryStream.h | 6 +++--- 1 file 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(m_bytes.size())) + if (offset > static_cast(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(m_offset) >= static_cast(m_bytes.size())) + if (offset + static_cast(m_offset) > static_cast(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(m_bytes.size())) + if (offset > static_cast(m_bytes.size())) return Error::from_string_literal("Offset past the start of the stream memory"); m_offset = m_bytes.size() - offset;