summaryrefslogtreecommitdiffstats
path: root/crypto/engine/eng_rdrand.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/engine/eng_rdrand.c')
-rw-r--r--crypto/engine/eng_rdrand.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/engine/eng_rdrand.c b/crypto/engine/eng_rdrand.c
index 39e4055a90..f46a514597 100644
--- a/crypto/engine/eng_rdrand.c
+++ b/crypto/engine/eng_rdrand.c
@@ -87,9 +87,19 @@ void engine_load_rdrand_int(void)
ENGINE *toadd = ENGINE_rdrand();
if (!toadd)
return;
+ ERR_set_mark();
ENGINE_add(toadd);
+ /*
+ * If the "add" worked, it gets a structural reference. So either way, we
+ * release our just-created reference.
+ */
ENGINE_free(toadd);
- ERR_clear_error();
+ /*
+ * If the "add" didn't work, it was probably a conflict because it was
+ * already added (eg. someone calling ENGINE_load_blah then calling
+ * ENGINE_load_builtin_engines() perhaps).
+ */
+ ERR_pop_to_mark();
}
}
#else