Rearrange the conditionals so that I always perform the Free if I got back a non-zero pointer, but only perform the Marshal if I got back a valid pointer and a good status code.
This commit is contained in:
@@ -28,12 +28,15 @@ namespace NSspi
|
||||
{
|
||||
status = NativeMethods.QuerySecurityPackageInfo( packageName, ref rawInfoPtr );
|
||||
|
||||
if( status == SecurityStatus.OK && rawInfoPtr != IntPtr.Zero )
|
||||
if ( rawInfoPtr != IntPtr.Zero )
|
||||
{
|
||||
try
|
||||
{
|
||||
// This performs allocations as it makes room for the strings contained in the SecPkgInfo class.
|
||||
Marshal.PtrToStructure( rawInfoPtr, info );
|
||||
if ( status == SecurityStatus.OK )
|
||||
{
|
||||
// This performs allocations as it makes room for the strings contained in the SecPkgInfo class.
|
||||
Marshal.PtrToStructure( rawInfoPtr, info );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user