Skip to content

Commit

Permalink
Bail if the sample value is less than the required minimum length by …
Browse files Browse the repository at this point in the history
…the slice.
  • Loading branch information
alrz committed Oct 22, 2021
1 parent 7dc82d4 commit b3db969
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/PatternExplainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,11 @@ string tryHandleListPattern(ref bool unnamedEnumValue)
return null;
}

// The sample value must be equal or greater than the required minimum length by the slice.
Debug.Assert(slice.StartIndex - slice.EndIndex <= lengthValue);
if (slice.StartIndex - slice.EndIndex > lengthValue)
{
// Bail if the sample value is less than the required minimum length by the slice.
return null;
}
}

var subpatterns = new ArrayBuilder<string>(lengthValue);
Expand Down

0 comments on commit b3db969

Please sign in to comment.