RT3246: req command prints version number wrong
[oweals/openssl.git] / crypto / engine / eng_table.c
index 4f28abca3401bd9cf29e7fc6612320cc50679969..74e1adf2582303ae4fa3be9463e0011a1d019d4d 100644 (file)
@@ -110,8 +110,8 @@ static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b)
        {
        return a->nid - b->nid;
        }
-static IMPLEMENT_LHASH_HASH_FN(engine_pile, const ENGINE_PILE)
-static IMPLEMENT_LHASH_COMP_FN(engine_pile, const ENGINE_PILE)
+static IMPLEMENT_LHASH_HASH_FN(engine_pile, ENGINE_PILE)
+static IMPLEMENT_LHASH_COMP_FN(engine_pile, ENGINE_PILE)
 
 static int int_table_check(ENGINE_TABLE **t, int create)
        {
@@ -157,7 +157,7 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
                                goto end;
                                }
                        fnd->funct = NULL;
-                       lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
+                       (void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd);
                        }
                /* A registration shouldn't add duplciate entries */
                (void)sk_ENGINE_delete_ptr(fnd->sk, e);
@@ -189,7 +189,7 @@ end:
 static void int_unregister_cb_doall_arg(ENGINE_PILE *pile, ENGINE *e)
        {
        int n;
-       /* Iterate the 'c->sk' stack removing any occurance of 'e' */
+       /* Iterate the 'c->sk' stack removing any occurrence of 'e' */
        while((n = sk_ENGINE_find(pile->sk, e)) >= 0)
                {
                (void)sk_ENGINE_delete(pile->sk, n);
@@ -254,6 +254,7 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, in
 #endif
                return NULL;
                }
+       ERR_set_mark();
        CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        /* Check again inside the lock otherwise we could race against cleanup
         * operations. But don't worry about a fprintf(stderr). */
@@ -327,7 +328,7 @@ end:
        CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Whatever happened, any failed init()s are not failures in this
         * context, so clear our error state. */
-       ERR_clear_error();
+       ERR_pop_to_mark();
        return ret;
        }
 
@@ -345,6 +346,8 @@ void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
        ENGINE_PILE_DOALL dall;
        dall.cb = cb;
        dall.arg = arg;
-       lh_ENGINE_PILE_doall_arg(&table->piles, LHASH_DOALL_ARG_FN(int_cb),
-                                ENGINE_PILE_DOALL, &dall);
+       if (table)
+               lh_ENGINE_PILE_doall_arg(&table->piles,
+                               LHASH_DOALL_ARG_FN(int_cb),
+                               ENGINE_PILE_DOALL, &dall);
        }