From 2685125f05288998fdc5625ba6ed5407155df036 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 2 Dec 2017 13:04:11 -0800 Subject: [PATCH] ircd::openssl: Fix memleak. --- ircd/openssl.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ircd/openssl.cc b/ircd/openssl.cc index 43e209226..313050ce1 100644 --- a/ircd/openssl.cc +++ b/ircd/openssl.cc @@ -48,8 +48,13 @@ ircd::const_raw_buffer ircd::openssl::cert2d(const mutable_raw_buffer &out, const string_view &cert) { - X509 x509 {0}; - return i2d(out, read(&x509, cert)); + const custom_ptr x509 + { + X509_new(), + [](X509 *const x509) { X509_free(x509); } + }; + + return i2d(out, read(x509.get(), cert)); } X509 &