Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 823e019

Browse files
dotnet-bottarekgh
authored andcommitted
Fix the fired asset in CompareInfo.IndexOf (dotnet/coreclr#16373) (#27128)
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 46267c1 commit 823e019

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Common/src/CoreLib/System/Globalization/CompareInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,11 @@ public unsafe virtual int IndexOf(string source, char value, int startIndex, int
841841
if (count < 0 || startIndex > source.Length - count)
842842
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count);
843843

844+
if (source.Length == 0)
845+
{
846+
return -1;
847+
}
848+
844849
if (options == CompareOptions.OrdinalIgnoreCase)
845850
{
846851
return source.IndexOf(value.ToString(), startIndex, count, StringComparison.OrdinalIgnoreCase);
@@ -850,7 +855,7 @@ public unsafe virtual int IndexOf(string source, char value, int startIndex, int
850855
// Ordinal can't be selected with other flags
851856
if ((options & ValidIndexMaskOffFlags) != 0 && (options != CompareOptions.Ordinal))
852857
throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options));
853-
858+
854859
if (_invariantMode)
855860
return IndexOfOrdinal(source, new string(value, 1), startIndex, count, ignoreCase: (options & (CompareOptions.IgnoreCase | CompareOptions.OrdinalIgnoreCase)) != 0);
856861

@@ -1281,7 +1286,7 @@ public virtual int GetHashCode(string source, CompareOptions options)
12811286
}
12821287

12831288
//
1284-
// GetHashCodeOfString does more parameters validation. basically will throw when
1289+
// GetHashCodeOfString does more parameters validation. basically will throw when
12851290
// having Ordinal, OrdinalIgnoreCase and StringSort
12861291
//
12871292

0 commit comments

Comments
 (0)