提交 27e74e82 编写于 作者: J Jan Kotas 提交者: Dan Moseley

Fix unbounded stackalloc in System.IO.FileSystem (dotnet/corefx#28004)



Commit migrated from https://github.com/dotnet/corefx/commit/bf36018813d2724e5bc9140d72e0d8bf92f2b621
上级 08cb6e35
......@@ -34,7 +34,7 @@ public static string TranslateWin32Expression(string expression)
return "*";
bool modified = false;
Span<char> stackSpace = stackalloc char[expression.Length];
Span<char> stackSpace = stackalloc char[32];
ValueStringBuilder sb = new ValueStringBuilder(stackSpace);
int length = expression.Length;
for (int i = 0; i < length; i++)
......
......@@ -143,5 +143,12 @@ public void TranslateExpression(string expression, string expected)
{
Assert.Equal(expected, FileSystemName.TranslateWin32Expression(expression));
}
[Fact]
public void TranslateVeryLongExpression()
{
string longString = new string('a', 10_000_000);
Assert.Equal(longString, FileSystemName.TranslateWin32Expression(longString));
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册