LastIndexOf corner case fix when span is empty (#18826)
authorViktor Hofer <viktor.hofer@microsoft.com>
Sun, 8 Jul 2018 17:41:40 +0000 (19:41 +0200)
committerGitHub <noreply@github.com>
Sun, 8 Jul 2018 17:41:40 +0000 (19:41 +0200)
src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs

index 58d0b5c..4e84223 100644 (file)
@@ -188,7 +188,7 @@ namespace System
 
             if (value.Length == 0)
             {
-                return span.Length - 1;
+                return span.Length > 0 ? span.Length - 1 : 0;
             }
 
             if (span.Length == 0)