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

Commit 08c80c5

Browse files
hughbejkotas
authored andcommitted
Fix OOM exception thrown in case insensitive replace for an empty string (#11001)
1 parent 2652383 commit 08c80c5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/mscorlib/src/System/String.Manipulation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ private unsafe String ReplaceCore(string oldValue, string newValue, CultureInfo
10221022
{
10231023
if (oldValue == null)
10241024
throw new ArgumentNullException(nameof(oldValue));
1025+
if (oldValue.Length == 0)
1026+
throw new ArgumentException(SR.Argument_StringZeroLength, nameof(oldValue));
10251027

10261028
// If they asked to replace oldValue with a null, replace all occurences
10271029
// with the empty string.

0 commit comments

Comments
 (0)