From 5e75a1fb992ad14172959f62efa24e9862d16e1f Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Mon, 29 Oct 2018 10:52:56 +0500 Subject: [PATCH] src/Mayaqua/Encrypt.c: fix memory leak occasionally found by valgrind --- src/Mayaqua/Encrypt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mayaqua/Encrypt.c b/src/Mayaqua/Encrypt.c index 1c24cbbd..9d2c1a0d 100644 --- a/src/Mayaqua/Encrypt.c +++ b/src/Mayaqua/Encrypt.c @@ -2357,6 +2357,7 @@ bool RsaCheck() ret = BN_set_word(e, RSA_F4); if (ret == 0) { + BN_free(e); Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf)); return false; } @@ -2366,6 +2367,7 @@ bool RsaCheck() { rsa = RSA_new(); ret = RSA_generate_key_ex(rsa, bit, e, NULL); + BN_free(e); } Unlock(openssl_lock); if (ret == 0) @@ -2438,6 +2440,7 @@ bool RsaGen(K **priv, K **pub, UINT bit) ret = BN_set_word(e, RSA_F4); if (ret == 0) { + BN_free(e); Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf)); return false; } @@ -2447,6 +2450,7 @@ bool RsaGen(K **priv, K **pub, UINT bit) { rsa = RSA_new(); ret = RSA_generate_key_ex(rsa, bit, e, NULL); + BN_free(e); } Unlock(openssl_lock); if (ret == 0)