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)