diff --git a/core/crypto/crypto.h b/core/crypto/crypto.h index bc7a4183fa6..0f4adecd233 100644 --- a/core/crypto/crypto.h +++ b/core/crypto/crypto.h @@ -83,6 +83,7 @@ public: virtual PoolByteArray finish() = 0; HMACContext() {} + virtual ~HMACContext() {} }; class Crypto : public Reference { diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp index 1976338840f..a2368c7e3ed 100644 --- a/modules/mbedtls/crypto_mbedtls.cpp +++ b/modules/mbedtls/crypto_mbedtls.cpp @@ -255,6 +255,13 @@ PoolByteArray HMACContextMbedTLS::finish() { return out; } +HMACContextMbedTLS::~HMACContextMbedTLS() { + if (ctx != nullptr) { + mbedtls_md_free((mbedtls_md_context_t *)ctx); + memfree((mbedtls_md_context_t *)ctx); + } +} + Crypto *CryptoMbedTLS::create() { return memnew(CryptoMbedTLS); } diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h index 3e46aef4182..dd509beba5b 100644 --- a/modules/mbedtls/crypto_mbedtls.h +++ b/modules/mbedtls/crypto_mbedtls.h @@ -119,6 +119,7 @@ public: virtual PoolByteArray finish(); HMACContextMbedTLS() {} + ~HMACContextMbedTLS(); }; class CryptoMbedTLS : public Crypto {