1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-18 01:33:00 +03:00

Merge pull request #781 from chipitsine/BN_free

Merge PR #781: src/Mayaqua/Encrypt.c: fix memory leak occasionally found by valgrind
This commit is contained in:
Ilya Shipitsin 2018-10-29 14:22:45 +05:00 committed by GitHub
commit 8da2464831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2357,6 +2357,7 @@ bool RsaCheck()
ret = BN_set_word(e, RSA_F4); ret = BN_set_word(e, RSA_F4);
if (ret == 0) if (ret == 0)
{ {
BN_free(e);
Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf)); Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf));
return false; return false;
} }
@ -2366,6 +2367,7 @@ bool RsaCheck()
{ {
rsa = RSA_new(); rsa = RSA_new();
ret = RSA_generate_key_ex(rsa, bit, e, NULL); ret = RSA_generate_key_ex(rsa, bit, e, NULL);
BN_free(e);
} }
Unlock(openssl_lock); Unlock(openssl_lock);
if (ret == 0) if (ret == 0)
@ -2438,6 +2440,7 @@ bool RsaGen(K **priv, K **pub, UINT bit)
ret = BN_set_word(e, RSA_F4); ret = BN_set_word(e, RSA_F4);
if (ret == 0) if (ret == 0)
{ {
BN_free(e);
Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf)); Debug("BN_set_word: err=%s\n", ERR_error_string(ERR_get_error(), errbuf));
return false; return false;
} }
@ -2447,6 +2450,7 @@ bool RsaGen(K **priv, K **pub, UINT bit)
{ {
rsa = RSA_new(); rsa = RSA_new();
ret = RSA_generate_key_ex(rsa, bit, e, NULL); ret = RSA_generate_key_ex(rsa, bit, e, NULL);
BN_free(e);
} }
Unlock(openssl_lock); Unlock(openssl_lock);
if (ret == 0) if (ret == 0)