Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update IndexOf checks for consistency
  • Loading branch information
hrrrrustic committed Jul 12, 2021
commit 1fd3d1ba5d24327c15dffdc41eb5e2580005600d
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,15 @@ public StringSegment Subsegment(int offset, int length)
public int IndexOf(char c, int start, int count)
{
int index = -1;
int offset = Offset + start;

if (HasValue)
{
if (start < 0 || (uint)offset > (uint)Buffer.Length)
if (start < 0 || start > Length)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
}

if (count < 0)
if (count < 0 || start + count > Length)
{
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.count);
}
Expand Down