Skip to content

Commit 6ad127b

Browse files
committed
(LOG4NET-671) Dispose WindowsIdentity in TryGetCurrentUserName()
1 parent 86fcc53 commit 6ad127b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/log4net/Core/LoggingEvent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,10 @@ private static string TryGetCurrentUserName()
931931

932932
try
933933
{
934-
var windowsIdentity = WindowsIdentity.GetCurrent();
935-
return windowsIdentity?.Name ?? "";
934+
using (WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent())
935+
{
936+
return windowsIdentity?.Name ?? "";
937+
}
936938
}
937939
catch (PlatformNotSupportedException)
938940
{

0 commit comments

Comments
 (0)