aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2019-07-07 16:42:46 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2019-07-07 16:43:08 +0300
commit7e94620db548fa4810797e9237d3722e0b1861ab (patch)
tree0f78e6c06da218ad60d425eb41cee44e38805bc6
parentadb069792952342b537b8d54461a7817097ae3da (diff)
downloadgost-engine-7e94620db548fa4810797e9237d3722e0b1861ab.zip
gost-engine-7e94620db548fa4810797e9237d3722e0b1861ab.tar.gz
gost-engine-7e94620db548fa4810797e9237d3722e0b1861ab.tar.bz2
Avoid memory leaks
Fixes #149.
-rw-r--r--gost_eng.c1
-rw-r--r--gost_grasshopper_cipher.c13
-rw-r--r--gost_grasshopper_cipher.h1
3 files changed, 15 insertions, 0 deletions
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