From 51d5655efa6ab61063db2e37e2571a22621a9b7c Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 1 Dec 2012 22:26:40 +0400 Subject: [PATCH] crypto: fix leak in GetPeerCertificate --- src/node_crypto.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index f41b2d5a8c6..209d8800628 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1532,6 +1532,15 @@ Handle Connection::GetPeerCertificate(const Arguments& args) { (void) BIO_reset(bio); } + if (pkey != NULL) { + EVP_PKEY_free(pkey); + pkey = NULL; + } + if (rsa != NULL) { + RSA_free(rsa); + rsa = NULL; + } + ASN1_TIME_print(bio, X509_get_notBefore(peer_cert)); BIO_get_mem_ptr(bio, &mem); info->Set(valid_from_symbol, String::New(mem->data, mem->length));