Skip to content

Commit 84a732f

Browse files
universorumgithub-actions
authored andcommitted
Use new char[] to instead potentially unbounded stackalloc
1 parent 353ebfc commit 84a732f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToHexString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static unsafe void ToHexString(byte[] input, string expected)
193193
[MemberData(nameof(ToHexStringTestData))]
194194
public static unsafe void TryToHexString(byte[] input, string expected)
195195
{
196-
Span<char> output = stackalloc char[expected.Length];
196+
Span<char> output = new char[expected.Length];
197197
Assert.True(Convert.TryToHexString(input, output, out int charsWritten));
198198
Assert.Equal(expected.Length, charsWritten);
199199
Assert.Equal(expected, output.ToString());
@@ -212,7 +212,7 @@ public static unsafe void ToHexStringLower(byte[] input, string expected)
212212
[MemberData(nameof(ToHexStringTestData))]
213213
public static unsafe void TryToHexStringLower(byte[] input, string expected)
214214
{
215-
Span<char> output = stackalloc char[expected.Length];
215+
Span<char> output = new char[expected.Length];
216216
Assert.True(Convert.TryToHexStringLower(input, output, out int charsWritten));
217217
Assert.Equal(expected.Length, charsWritten);
218218
Assert.Equal(expected.ToLower(), output.ToString());

0 commit comments

Comments
 (0)