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:
@@ -155,12 +155,18 @@ namespace NSspi.Credentials
|
||||
this.safeCredHandle.DangerousRelease();
|
||||
|
||||
if( status == SecurityStatus.OK && carrier.Name != IntPtr.Zero )
|
||||
{
|
||||
try
|
||||
{
|
||||
name = Marshal.PtrToStringUni( carrier.Name );
|
||||
}
|
||||
finally
|
||||
{
|
||||
NativeMethods.FreeContextBuffer( carrier.Name );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( status.IsError() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user