Don't clear the whole error stack when loading engines
[openssl.git] / crypto / engine / eng_dyn.c
index 01935578c26ad1d068644123a952cf6e48cc6258..3b0d8eb91f770bee0bd2590d2f52ab1b114cb6d3 100644 (file)
@@ -257,6 +257,8 @@ void engine_load_dynamic_int(void)
     ENGINE *toadd = engine_dynamic();
     if (!toadd)
         return;
+
+    ERR_set_mark();
     ENGINE_add(toadd);
     /*
      * If the "add" worked, it gets a structural reference. So either way, we
@@ -268,7 +270,7 @@ void engine_load_dynamic_int(void)
      * already added (eg. someone calling ENGINE_load_blah then calling
      * ENGINE_load_builtin_engines() perhaps).
      */
-    ERR_clear_error();
+    ERR_pop_to_mark();
 }
 
 static int dynamic_init(ENGINE *e)