From: Matt Caswell Date: Tue, 17 Jul 2018 09:47:08 +0000 (+0100) Subject: Fix a mem leak X-Git-Tag: v3.0.0~415^2 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F68%2Fhead;p=openssl-gost%2Fengine.git Fix a mem leak Ensure the grasshopper ciphers are destroyed on engine destroy. --- diff --git a/gost_eng.c b/gost_eng.c index 16316a1..517a7da 100644 --- a/gost_eng.c +++ b/gost_eng.c @@ -110,6 +110,7 @@ static int gost_engine_destroy(ENGINE* e) { imit_gost_cp_12_destroy(); cipher_gost_destroy(); + cipher_gost_grasshopper_destroy(); gost_param_free(); diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index c797fe1..2cce251 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -650,6 +650,20 @@ const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_ctr() { return cipher_gost_grasshopper(EVP_CIPH_CTR_MODE, GRASSHOPPER_CIPHER_CTR); } +void cipher_gost_grasshopper_destroy(void) +{ + EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_ECB]); + gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_ECB] = NULL; + EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CBC]); + gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CBC] = NULL; + EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_OFB]); + gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_OFB] = NULL; + EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CFB]); + gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CFB] = NULL; + EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CTR]); + gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CTR] = NULL; +} + #if defined(__cplusplus) } #endif diff --git a/gost_grasshopper_cipher.h b/gost_grasshopper_cipher.h index edd45a4..08aac05 100644 --- a/gost_grasshopper_cipher.h +++ b/gost_grasshopper_cipher.h @@ -100,6 +100,8 @@ extern const EVP_CIPHER* cipher_gost_grasshopper_ofb(); extern const EVP_CIPHER* cipher_gost_grasshopper_cfb(); extern const EVP_CIPHER* cipher_gost_grasshopper_ctr(); +void cipher_gost_grasshopper_destroy(void); + #if defined(__cplusplus) } #endif