Commit deca5df2 authored by Matt Caswell's avatar Matt Caswell
Browse files

If we've not been inited don't deinit



If you call an explicit deinit when we've not been inited then a seg
fault can occur. We should check that we've been inited before attempting
to deinit.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 740b2b9a
Loading
Loading
Loading
Loading
+18 −16
Original line number Diff line number Diff line
@@ -537,6 +537,10 @@ void OPENSSL_INIT_library_stop(void)
{
    OPENSSL_INIT_STOP *currhandler, *lasthandler;

    /* If we've not been inited then no need to deinit */
    if (!base_inited)
        return;

    /*
     * Thread stop may not get automatically called by the thread library for
     * the very last thread in some situations, so call it directly.
@@ -613,7 +617,6 @@ void OPENSSL_INIT_library_stop(void)
        OPENSSL_INIT_ONCE_DYNAMIC_INIT(&load_crypto_strings);
    }

    if (base_inited) {
#ifdef OPENSSL_INIT_DEBUG
    fprintf(stderr, "OPENSSL_INIT: OPENSSL_INIT_library_stop: "
                    "CRYPTO_cleanup_all_ex_data()\n");
@@ -631,7 +634,6 @@ void OPENSSL_INIT_library_stop(void)
    base_inited = 0;
    OPENSSL_INIT_ONCE_DYNAMIC_INIT(&base);
}
}

static const OPENSSL_INIT_SETTINGS *ossl_init_get_setting(
        const OPENSSL_INIT_SETTINGS *settings, int name)