Commit 4a8052bb8b for openssl.org
commit 4a8052bb8bb07f36f9d3bd098fd835e9ddb04c47
Author: Neil Horman <nhorman@openssl.org>
Date: Fri May 8 19:16:28 2026 -0400
delay method store free in context_deinit_objs
Reviewed-by: Bob Beck <beck@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
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 3596c0e068..66d7e42955 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);