Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAtsushi Kanamori <AtsushiKan@users.noreply.github.com>2017-05-17 19:50:46 +0300
committerGitHub <noreply@github.com>2017-05-17 19:50:46 +0300
commit201a10035f1965a1d70e5ed64ca6495809bbb631 (patch)
tree56816565bb497af288b6d32e94b572ac2d4029c9 /src
parentd73512863b7a08a6106c78446346327da8063f34 (diff)
Fix some corefx testing regressions due to multidim rank-1 (#3636)
Passing a negative length to an api that creates multidim arrays throws OverflowException rather than ArgumentOutOfRangeException (presumably due to the assumption that we overflowed while computing the size rather than a specific bad length being passed in.)
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs b/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
index 67c6378c8..ce2131230 100644
--- a/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
+++ b/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs
@@ -152,7 +152,10 @@ namespace Internal.Runtime.Augments
// We just checked above that all lower bounds are zero. In that case, we should actually allocate
// a new SzArray instead.
RuntimeTypeHandle elementTypeHandle = new RuntimeTypeHandle(typeHandleForArrayType.ToEETypePtr().ArrayElementType);
- return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), lengths[0]);
+ int length = lengths[0];
+ if (length < 0)
+ throw new OverflowException(); // For compat: we need to throw OverflowException(): Array.CreateInstance throws ArgumentOutOfRangeException()
+ return Array.CreateInstance(Type.GetTypeFromHandle(elementTypeHandle), length);
}
// Create a local copy of the lenghts that cannot be motified by the caller