diff options
author | Jack Lloyd <[email protected]> | 2018-12-03 21:58:16 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-03 21:58:16 -0500 |
commit | e0ce7d226174135831202a2468a18411c427b914 (patch) | |
tree | dda05fd1e66c22058e28d59355df355327fb6f10 /src/lib/prov/openssl/openssl_ec.cpp | |
parent | ecabbbd96c373d1cb2143f5bfddf6745a75f40e0 (diff) |
Fix a memory leak in OpenSSL ECDH
Diffstat (limited to 'src/lib/prov/openssl/openssl_ec.cpp')
-rw-r--r-- | src/lib/prov/openssl/openssl_ec.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/prov/openssl/openssl_ec.cpp b/src/lib/prov/openssl/openssl_ec.cpp index 026dfa5e0..53ed081a1 100644 --- a/src/lib/prov/openssl/openssl_ec.cpp +++ b/src/lib/prov/openssl/openssl_ec.cpp @@ -328,20 +328,22 @@ class OpenSSL_ECDH_KA_Operation final : public PK_Ops::Key_Agreement_with_KDF const EC_GROUP* group = ::EC_KEY_get0_group(m_ossl_ec.get()); const size_t out_len = (::EC_GROUP_get_degree(group) + 7) / 8; secure_vector<uint8_t> out(out_len); - EC_POINT* pub_key = ::EC_POINT_new(group); + + std::unique_ptr<EC_POINT, std::function<void (EC_POINT*)>> pub_key( + ::EC_POINT_new(group), ::EC_POINT_free); if(!pub_key) throw OpenSSL_Error("EC_POINT_new", ERR_get_error()); const int os2ecp_rc = - ::EC_POINT_oct2point(group, pub_key, w, w_len, nullptr); + ::EC_POINT_oct2point(group, pub_key.get(), w, w_len, nullptr); if(os2ecp_rc != 1) throw OpenSSL_Error("EC_POINT_oct2point", ERR_get_error()); const int ecdh_rc = ::ECDH_compute_key(out.data(), out.size(), - pub_key, + pub_key.get(), m_ossl_ec.get(), /*KDF*/nullptr); |