[Crypto] Delete mbedtls ctx in deconstructor.
Would cause memory leak when the context was `start`ed but not
`finish`ed.
(cherry picked from commit a28d25c441
)
This commit is contained in:
parent
245b9400ea
commit
32e91b232c
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue