From 9310dde83bacdacdc8af57447f2949bd2d2213c1 Mon Sep 17 00:00:00 2001 From: antiduh Date: Fri, 27 Jun 2014 00:18:31 +0000 Subject: [PATCH] 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. --- PackageSupport.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PackageSupport.cs b/PackageSupport.cs index dc1f72a..f7d4ccd 100644 --- a/PackageSupport.cs +++ b/PackageSupport.cs @@ -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 {