Increase the reliability of QueryCredentialsAttribute_Name usage by wrapping a try-finally around the allocation that happens inside the CER.

This commit is contained in:
antiduh
2014-06-28 16:46:21 +00:00
parent 241da896b1
commit 60ea145e86

View File

@@ -156,8 +156,14 @@ namespace NSspi.Credentials
if( status == SecurityStatus.OK && carrier.Name != IntPtr.Zero )
{
name = Marshal.PtrToStringUni( carrier.Name );
NativeMethods.FreeContextBuffer( carrier.Name );
try
{
name = Marshal.PtrToStringUni( carrier.Name );
}
finally
{
NativeMethods.FreeContextBuffer( carrier.Name );
}
}
}
}