Skip to content

Commit

Permalink
Fix more off-by-one errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Oct 9, 2024
1 parent a3817ef commit 52cc5db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions source/numem/io/stream/filestream.d
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ override:
}

ptrdiff_t read(ref vector!ubyte buffer, size_t offset, size_t count) {
if (offset+count >= buffer.size()) return -2;
if (offset+count > buffer.size()) return -2;

fPosition_ += buffer.size;
return fread(buffer.data+offset, 1, count, file);
Expand All @@ -91,7 +91,7 @@ override:

ptrdiff_t write(ref vector!ubyte buffer, int offset, int count) {

if (offset+count >= buffer.size()) return -2;
if (offset+count > buffer.size()) return -2;

// NOTE: Write and calculate the position delta
// said delta is used to recalculate the length
Expand Down
2 changes: 1 addition & 1 deletion source/numem/io/stream/memstream.d
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ override:
ptrdiff_t toWrite = count;

// Out of range for source
if (offset+count >= buffer.size()) return -2;
if (offset+count > buffer.length) return -2;

// Limit read to bounds
if (fPosition_+count > fLength_)
Expand Down

0 comments on commit 52cc5db

Please sign in to comment.