Skip to content

Commit a84d854

Browse files
authored
Fix SliceStream.Seek offset check (#19)
* Fix SliceStream.Seek offset check Suppose that SliceStream has zero length. At the creation `Position` will have value `0` and. The check in `Seek` method would prevent reassigning the `0` to `Position` property which should be perfectly valid. * Fix the exception message too
1 parent 7549238 commit a84d854

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/LibObjectFile/Utils/SliceStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public override long Seek(long offset, SeekOrigin origin)
9191
}
9292

9393
if (newPosition < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is < 0");
94-
if (newPosition >= _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is >= Length {_length}");
94+
if (newPosition > _length) throw new ArgumentOutOfRangeException(nameof(offset), $"New resulting position {newPosition} is > Length {_length}");
9595

9696
// Check that we can seek on the origin stream
9797
_baseStream.Position = _basePosition + newPosition;
@@ -145,4 +145,4 @@ public override void Write(byte[] buffer, int offset, int count)
145145
}
146146
}
147147
}
148-
}
148+
}

0 commit comments

Comments
 (0)