Browse Source

Skip rangecheck in string.EndsWith(char) (dotnet/coreclr#22206)

Signed-off-by: dotnet-bot <[email protected]>
Ben Adams 7 years ago
parent
commit
ed3649661e
1 changed files with 2 additions and 2 deletions
  1. 2 2
      netcore/System.Private.CoreLib/shared/System/String.Comparison.cs

+ 2 - 2
netcore/System.Private.CoreLib/shared/System/String.Comparison.cs

@@ -594,8 +594,8 @@ namespace System
 
         public bool EndsWith(char value)
         {
-            int thisLen = Length;
-            return thisLen != 0 && this[thisLen - 1] == value;
+            int lastPos = Length - 1;
+            return ((uint)lastPos < (uint)Length) && this[lastPos] == value;
         }
 
         // Determines whether two strings match.