Would cause memory leak when the context was `start`ed but not `finish`ed. (cherry picked from commit a28d25c44181ded80c80f7ae18ea75ce28e00eec)
@@ -83,6 +83,7 @@ public:
virtual PoolByteArray finish() = 0;
HMACContext() {}
+ virtual ~HMACContext() {}
};
class Crypto : public Reference {
@@ -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);
@@ -119,6 +119,7 @@ public:
virtual PoolByteArray finish();
HMACContextMbedTLS() {}
+ ~HMACContextMbedTLS();
class CryptoMbedTLS : public Crypto {