Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit bdba43d

Browse files
ViktorHoferstephentoub
authored andcommitted
Use stackalloc for longer SystemDirectory paths (#27204)
* Use stackalloc for longer SystemDirectory paths * change stackalloc to 260
1 parent ef8ed75 commit bdba43d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/System.Runtime.Extensions/src/System/Environment.Windows.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ public static string SystemDirectory
149149
{
150150
get
151151
{
152-
// The path will likely be under 32 characters, e.g. C:\Windows\system32
153-
Span<char> buffer = stackalloc char[32];
152+
Span<char> buffer = stackalloc char[260];
154153
int requiredSize = Interop.Kernel32.GetSystemDirectoryW(buffer);
155154

156155
if (requiredSize > buffer.Length)

0 commit comments

Comments
 (0)