Browse Source

LibCore: Allow `MemoryStream::seek` to go to EOF

The method still prevents you to go out of bound.
Lucas CHOLLET 2 years ago
parent
commit
db40a514f5
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Userland/Libraries/LibCore/MemoryStream.h

+ 3 - 3
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;