Use stackalloc for longer SystemDirectory paths (dotnet/corefx#27204)
authorViktor Hofer <viktor.hofer@microsoft.com>
Fri, 16 Feb 2018 18:01:27 +0000 (19:01 +0100)
committerStephen Toub <stoub@microsoft.com>
Fri, 16 Feb 2018 18:01:27 +0000 (13:01 -0500)
* Use stackalloc for longer SystemDirectory paths

* change stackalloc to 260

Commit migrated from https://github.com/dotnet/corefx/commit/bdba43d52e44ed9f2d194ab5b151aa47c60edbf4

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

index a835b07..20da5bb 100644 (file)
@@ -149,8 +149,7 @@ namespace System
         {
             get
             {
-                // The path will likely be under 32 characters, e.g. C:\Windows\system32
-                Span<char> buffer = stackalloc char[32];
+                Span<char> buffer = stackalloc char[260];
                 int requiredSize = Interop.Kernel32.GetSystemDirectoryW(buffer);
 
                 if (requiredSize > buffer.Length)