From 015ced7c92c5a04b451413ebf7a814830e87edf9 Mon Sep 17 00:00:00 2001 From: Hugh Bellamy Date: Mon, 17 Apr 2017 01:36:47 +0700 Subject: [PATCH] Fix OOM exception thrown in case insensitive replace for an empty string (dotnet/coreclr#11001) Commit migrated from https://github.com/dotnet/coreclr/commit/08c80c57b08647be4b3d050549f48bbe265ad90e --- src/coreclr/src/mscorlib/src/System/String.Manipulation.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/src/mscorlib/src/System/String.Manipulation.cs b/src/coreclr/src/mscorlib/src/System/String.Manipulation.cs index 33e341c..2b1f5a6 100644 --- a/src/coreclr/src/mscorlib/src/System/String.Manipulation.cs +++ b/src/coreclr/src/mscorlib/src/System/String.Manipulation.cs @@ -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. -- 2.7.4