diff options
Diffstat (limited to 'src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs')
-rw-r--r-- | src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs b/src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs index a594cc072d..f9235193b4 100644 --- a/src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs +++ b/src/System.Security.Cryptography.X509Certificates/src/Microsoft/Win32/SafeHandles/SafePasswordHandle.cs @@ -41,6 +41,25 @@ namespace Microsoft.Win32.SafeHandles return true; } + protected override void Dispose(bool disposing) + { + if (disposing && SafeHandleCache<SafePasswordHandle>.IsCachedInvalidHandle(this)) + { + return; + } + + base.Dispose(disposing); + } + public override bool IsInvalid => handle == (IntPtr)(-1); + + public static SafePasswordHandle InvalidHandle => + SafeHandleCache<SafePasswordHandle>.GetInvalidHandle( + () => + { + var handle = new SafePasswordHandle((string)null); + handle.handle = (IntPtr)(-1); + return handle; + }); } } |