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 );
|
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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user