crypto: fix X509 cert memory leak in GetPeerCert

`SSL_get_peer_certificate` returns referenced X509 object, we should
decrement the reference count once it is not needed.

Fix joyent/node#8674
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/node-forward/node/pull/56
This commit is contained in:
Fedor Indutny 2014-11-11 08:08:09 +03:00
Родитель be413ac732
Коммит 3b3d89bad2
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -1403,9 +1403,10 @@ void SSLWrap<Base>::GetPeerCertificate(
info->Set(env->issuercert_string(), info);
CHECK_NE(cert, nullptr);
X509_free(cert);
done:
if (cert != nullptr)
X509_free(cert);
if (peer_certs != nullptr)
sk_X509_pop_free(peer_certs, X509_free);
if (result.IsEmpty())