From 2b574b2c5e47937fbcc7a249455b907235f76a58 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 1 Aug 2017 12:59:23 -0400 Subject: [PATCH] [System]: Fix memory leak in BTLS. (#5291) --- mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs b/mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs index b9c83ae4383..29bfb5bbfd1 100644 --- a/mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs +++ b/mcs/class/System/Mono.Btls/X509CertificateImplBtls.cs @@ -303,6 +303,8 @@ namespace Mono.Btls return PKCS8.PrivateKeyInfo.DecodeRSA (bytes); } set { + if (nativePrivateKey != null) + nativePrivateKey.Dispose (); nativePrivateKey = null; FallbackImpl.PrivateKey = value; } @@ -490,6 +492,7 @@ namespace Mono.Btls x509 = null; } if (nativePrivateKey != null) { + nativePrivateKey.Dispose (); nativePrivateKey = null; } subjectName = null; -- 2.25.1