From 27d2b990e2fd4b4058fe21c2e1eaa4883e7bfa0b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 22 Dec 2024 18:31:30 +0800 Subject: [PATCH] Fix GetModuleFileName in GetProcessPath --- .../System.Private.CoreLib/src/System/Environment.Windows.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs index bd2cb5b10ff3f..b7bc78760e326 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.Windows.cs @@ -131,7 +131,7 @@ private static unsafe bool IsPrivilegedProcessCore() uint length; while ((length = Interop.Kernel32.GetModuleFileName(IntPtr.Zero, ref builder.GetPinnableReference(), (uint)builder.Capacity)) >= builder.Capacity) { - builder.EnsureCapacity((int)length); + builder.EnsureCapacity(builder.Length * 2); } if (length == 0)