From: Dmitry Belyavskiy Date: Sun, 7 Jul 2019 13:42:46 +0000 (+0300) Subject: Avoid memory leaks X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=7e94620db548fa4810797e9237d3722e0b1861ab;p=openssl-gost%2Fengine.git Avoid memory leaks Fixes #149. --- diff --git a/gost_eng.c b/gost_eng.c index 9e77e5d..a1dcd79 100644 --- a/gost_eng.c +++ b/gost_eng.c @@ -112,6 +112,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 92be991..cc59daf 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -624,6 +624,19 @@ 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 3a8531f..2aae662 100644 --- a/gost_grasshopper_cipher.h +++ b/gost_grasshopper_cipher.h @@ -98,6 +98,7 @@ 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