Merge pull request #50128 from Faless/mbedtls/hmac_free

[Crypto] Delete mbedtls ctx in deconstructor.
This commit is contained in:
Rémi Verschelde 2021-07-03 20:15:30 +02:00 committed by GitHub
commit af1543ded5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -82,6 +82,7 @@ public:
virtual PackedByteArray finish() = 0;
HMACContext() {}
virtual ~HMACContext() {}
};
class Crypto : public RefCounted {

View file

@ -249,6 +249,13 @@ PackedByteArray 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);
}

View file

@ -119,6 +119,7 @@ public:
virtual PackedByteArray finish();
HMACContextMbedTLS() {}
~HMACContextMbedTLS();
};
class CryptoMbedTLS : public Crypto {