From: Neil Horman Date: Fri, 8 May 2026 23:16:28 +0000 (-0400) Subject: delay method store free in context_deinit_objs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a8052bb8bb07f36f9d3bd098fd835e9ddb04c47;p=thirdparty%2Fopenssl.git delay method store free in context_deinit_objs Reviewed-by: Bob Beck Reviewed-by: Nikola Pajkovsky MergeDate: Thu Jun 25 21:26:15 2026 (Merged from https://github.com/openssl/openssl/pull/31143) --- diff --git a/crypto/context.c b/crypto/context.c index 3596c0e0683..66d7e429556 100644 --- a/crypto/context.c +++ b/crypto/context.c @@ -255,12 +255,6 @@ err: static void context_deinit_objs(OSSL_LIB_CTX *ctx) { - /* P2. We want evp_method_store to be cleaned up before the provider store */ - if (ctx->evp_method_store != NULL) { - ossl_method_store_free(ctx->evp_method_store); - ctx->evp_method_store = NULL; - } - /* P2. */ if (ctx->drbg != NULL) { ossl_rand_ctx_free(ctx->drbg); @@ -278,14 +272,14 @@ static void context_deinit_objs(OSSL_LIB_CTX *ctx) * P2. We want decoder_store/decoder_cache to be cleaned up before the * provider store */ - if (ctx->decoder_store != NULL) { - ossl_method_store_free(ctx->decoder_store); - ctx->decoder_store = NULL; - } if (ctx->decoder_cache != NULL) { ossl_decoder_cache_free(ctx->decoder_cache); ctx->decoder_cache = NULL; } + if (ctx->decoder_store != NULL) { + ossl_method_store_free(ctx->decoder_store); + ctx->decoder_store = NULL; + } /* P2. We want encoder_store to be cleaned up before the provider store */ if (ctx->encoder_store != NULL) { @@ -306,6 +300,12 @@ static void context_deinit_objs(OSSL_LIB_CTX *ctx) ctx->provider_store = NULL; } + /* P2. We want evp_method_store to be cleaned up before the provider store */ + if (ctx->evp_method_store != NULL) { + ossl_method_store_free(ctx->evp_method_store); + ctx->evp_method_store = NULL; + } + /* Default priority. */ if (ctx->property_string_data != NULL) { ossl_property_string_data_free(ctx->property_string_data);