From 6f45b8762c3b7cc2ebaaede1e5baf4fe32d9dedf Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 20 Feb 2014 22:24:59 -0600 Subject: clear the error you get if you get a NULL engine back --- cryptography/hazmat/bindings/openssl/osrandom_engine.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cryptography/hazmat/bindings/openssl/osrandom_engine.py b/cryptography/hazmat/bindings/openssl/osrandom_engine.py index bbb3d642..01e0c5dd 100644 --- a/cryptography/hazmat/bindings/openssl/osrandom_engine.py +++ b/cryptography/hazmat/bindings/openssl/osrandom_engine.py @@ -175,11 +175,12 @@ static RAND_METHOD osrandom_rand = { }; int Cryptography_add_osrandom_engine(void) { - ENGINE *engine = ENGINE_by_id(Cryptography_osrandom_engine_id); - if (engine != NULL) { - // The engine has already been added, - ENGINE_free(engine); + ENGINE *osrandom_engine = ENGINE_by_id(Cryptography_osrandom_engine_id); + if (osrandom_engine != NULL) { + ENGINE_free(osrandom_engine); return 2; + } else { + ERR_clear_error(); } ENGINE *e = ENGINE_new(); -- cgit v1.2.3