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:
antiduh
2014-06-27 00:18:31 +00:00
parent b55c367caa
commit 9310dde83b

View File

@@ -28,12 +28,15 @@ namespace NSspi
{ {
status = NativeMethods.QuerySecurityPackageInfo( packageName, ref rawInfoPtr ); status = NativeMethods.QuerySecurityPackageInfo( packageName, ref rawInfoPtr );
if( status == SecurityStatus.OK && rawInfoPtr != IntPtr.Zero ) if ( rawInfoPtr != IntPtr.Zero )
{ {
try try
{ {
// This performs allocations as it makes room for the strings contained in the SecPkgInfo class. if ( status == SecurityStatus.OK )
Marshal.PtrToStructure( rawInfoPtr, info ); {
// This performs allocations as it makes room for the strings contained in the SecPkgInfo class.
Marshal.PtrToStructure( rawInfoPtr, info );
}
} }
finally finally
{ {