From c41b682892c58cb8896f397086b917e9ba9c86c3 Mon Sep 17 00:00:00 2001 From: Atsushi Kanamori Date: Tue, 27 Jun 2017 11:51:28 -0700 Subject: [PATCH] Fix bad range check in TextInfo.IndexOfStringOrdinalIgnoreCase (dotnet/coreclr#12478) Breaks: int idx = "\uabcd".IndexOf("", 1, StringComparison.OrdinalIgnoreCase); should return 1, returns -1 instead. (propagated fix from CoreRT) Commit migrated from https://github.com/dotnet/coreclr/commit/53900a63a76cce3e054bd93d1533348edc2c71f1 --- src/coreclr/src/mscorlib/src/System/Globalization/TextInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/mscorlib/src/System/Globalization/TextInfo.cs b/src/coreclr/src/mscorlib/src/System/Globalization/TextInfo.cs index dd54257..9a62876 100644 --- a/src/coreclr/src/mscorlib/src/System/Globalization/TextInfo.cs +++ b/src/coreclr/src/mscorlib/src/System/Globalization/TextInfo.cs @@ -111,7 +111,7 @@ namespace System.Globalization // Currently we don't have native functions to do this, so we do it the hard way internal static int IndexOfStringOrdinalIgnoreCase(String source, String value, int startIndex, int count) { - if (count > source.Length || count < 0 || startIndex < 0 || startIndex >= source.Length || startIndex + count > source.Length) + if (count > source.Length || count < 0 || startIndex < 0 || startIndex > source.Length - count) { return -1; } -- 2.7.4