Skip to content

Commit

Permalink
Random fixes (dotnet#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky authored Mar 25, 2021
1 parent 4a57487 commit 92d54cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ public static Array CreateInstance(Type elementType, params int[] lengths)
if (lengths.Length == 0)
throw new ArgumentException(SR.Arg_NeedAtLeast1Rank);

// Check to make sure the lengths are all positive. Note that we check this here to give
// a good exception message if they are not; however we check this again inside the execution
// engine's low level allocation function after having made a copy of the array to prevent a
// malicious caller from mutating the array after this check.
for (int i = 0; i < lengths.Length; i++)
if (lengths[i] < 0)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.lengths, i, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);

if (lengths.Length == 1)
{
int length = lengths[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private static object GetDefaultValue(object targetMethodOrDelegate, RuntimeType
bool hasDefaultValue = RuntimeAugments.Callbacks.TryGetDefaultParameterValue(targetMethodOrDelegate, thType, argIndex, out object defaultValue);
if (!hasDefaultValue)
{
throw new ArgumentException(SR.Arg_DefaultValueMissingException);
throw new ArgumentException(SR.Arg_DefaultValueMissingException, "parameters");
}

// Note that we might return null even for value types which cannot have null value here.
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Common/tests/Tests/System/StringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7263,6 +7263,7 @@ public static unsafe void CopyTest()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtimelab/issues/823" /* NativeAot */)]
public static unsafe void InternTest()
{
AssertExtensions.Throws<ArgumentNullException>("str", () => string.Intern(null));
Expand Down

0 comments on commit 92d54cc

Please sign in to comment.