diff options
author | Marek Safar <marek.safar@gmail.com> | 2018-03-15 21:12:16 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-03-15 21:12:16 +0300 |
commit | 3af0d49e577721ff261a2428dd5eca20981fe8cb (patch) | |
tree | c45756eda0e2c3aa1cda5e585e2669744e606d4b | |
parent | ceff4fb1748c26be30a4100f28f97e46dbe294f2 (diff) |
Don't depend on crash handler when null argument is used
-rw-r--r-- | src/System.Private.CoreLib/src/System/String.cs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/src/System/String.cs b/src/System.Private.CoreLib/src/System/String.cs index 4ef655fbb..a10d212c0 100644 --- a/src/System.Private.CoreLib/src/System/String.cs +++ b/src/System.Private.CoreLib/src/System/String.cs @@ -297,6 +297,14 @@ namespace System if (startIndex < 0) throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); + if (value == null) + { + if (length == 0) + return Empty; + + throw new ArgumentNullException(nameof(value)); + } + byte* pStart = (byte*)(value + startIndex); if (pStart < value) { |