If an engine comes up explicitely, it must also come down explicitely
[oweals/openssl.git] / apps / apps.c
index 68f2f2710ac462dc10f33f76fe6a8bd1b7a6b749..05e1c2d009aeeed7b3117e99a4bc61aa98477da1 100644 (file)
@@ -1280,14 +1280,20 @@ ENGINE *setup_engine(const char *engine, int debug)
         }
 
         BIO_printf(bio_err, "engine \"%s\" set.\n", ENGINE_get_id(e));
-
-        /* Free our "structural" reference. */
-        ENGINE_free(e);
     }
     return e;
 }
 #endif
 
+void release_engine(ENGINE *e)
+{
+#ifndef OPENSSL_NO_ENGINE
+    if (e != NULL)
+        /* Free our "structural" reference. */
+        ENGINE_free(e);
+#endif
+}
+
 static unsigned long index_serial_hash(const OPENSSL_CSTRING *a)
 {
     const char *n;