Fix OOM exception thrown in case insensitive replace for an empty string (dotnet...
authorHugh Bellamy <hughbellars@gmail.com>
Sun, 16 Apr 2017 18:36:47 +0000 (01:36 +0700)
committerJan Kotas <jkotas@microsoft.com>
Sun, 16 Apr 2017 18:36:47 +0000 (11:36 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/08c80c57b08647be4b3d050549f48bbe265ad90e

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

index 33e341c..2b1f5a6 100644 (file)
@@ -1022,6 +1022,8 @@ namespace System
         {
             if (oldValue == null)
                 throw new ArgumentNullException(nameof(oldValue));
+            if (oldValue.Length == 0)
+                throw new ArgumentException(SR.Argument_StringZeroLength, nameof(oldValue));
 
             // If they asked to replace oldValue with a null, replace all occurences
             // with the empty string.