Fix memory leak when RAND is used: need to cleanup
authorDr. Stephen Henson <steve@openssl.org>
Thu, 21 Jun 2001 12:19:10 +0000 (12:19 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 21 Jun 2001 12:19:10 +0000 (12:19 +0000)
RANDs ENGINE reference in ENGINE_cleanup().

crypto/engine/engine_lib.c
crypto/rand/rand_lib.c

index 84efe9616358f396445bda38a8e9ebefd65cf422..f82a20ad0302070d136c302b245cf60988ccb39c 100644 (file)
@@ -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;
        }
index 38cea799380cc49af62e69fcdb4e8b51fd072dd5..adbae32ce358633be5cfcd3bb93777ade4e7fa55 100644 (file)
@@ -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