]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Avoid memory leaks
authorDmitry Belyavskiy <beldmit@gmail.com>
Sun, 7 Jul 2019 13:42:46 +0000 (16:42 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Sun, 7 Jul 2019 13:43:08 +0000 (16:43 +0300)
Fixes #149.

gost_eng.c
gost_grasshopper_cipher.c
gost_grasshopper_cipher.h

index 9e77e5dc6a605bcc87bab2c9acfc46c47a31994e..a1dcd790604c9ffe68c2d66bb8c61235eae234dd 100644 (file)
@@ -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();
 
index 92be9917be27660f4e3559731e337b9fa355a6aa..cc59dafb52ded8dc5bf9a8cce8a08c8888739bfa 100644 (file)
@@ -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
index 3a8531f454d577382cd9ced9767f956e4f8c03a7..2aae66274bf6d1b6a7a6ff5be0df2fa563322af7 100644 (file)
@@ -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