From: Dr. Stephen Henson Date: Thu, 21 Jun 2001 12:19:10 +0000 (+0000) Subject: Fix memory leak when RAND is used: need to cleanup X-Git-Tag: OpenSSL_0_9_6c~182^2~93 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ed5538dc2bf723388aba3aea332bf554c514dcfe;p=oweals%2Fopenssl.git Fix memory leak when RAND is used: need to cleanup RANDs ENGINE reference in ENGINE_cleanup(). --- diff --git a/crypto/engine/engine_lib.c b/crypto/engine/engine_lib.c index 84efe96163..f82a20ad03 100644 --- a/crypto/engine/engine_lib.c +++ b/crypto/engine/engine_lib.c @@ -856,7 +856,8 @@ int ENGINE_clear_defaults(void) #endif !ENGINE_set_default_RAND(NULL) || !ENGINE_set_default_BN_mod_exp(NULL) || - !ENGINE_set_default_BN_mod_exp_crt(NULL)) + !ENGINE_set_default_BN_mod_exp_crt(NULL) || + !RAND_set_rand_method(NULL)) return 0; return 1; } diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 38cea79938..adbae32ce3 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -74,11 +74,12 @@ int RAND_set_rand_method(ENGINE *engine) { ENGINE *mtmp; mtmp = rand_engine; - if (!ENGINE_init(engine)) + if (engine && !ENGINE_init(engine)) return 0; rand_engine = engine; /* SHOULD ERROR CHECK THIS!!! */ - ENGINE_finish(mtmp); + if(mtmp) + ENGINE_finish(mtmp); return 1; } #endif