Skip to content

Commit

Permalink
ossl_decoder_cache_flush(): Do not raise an error if there is no cache
Browse files Browse the repository at this point in the history
This function can be called during OPENSSL_cleanup() when
the cache was already flushed and deallocated.

Fixes #22939

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #22941)

(cherry picked from commit 0541fa7)
  • Loading branch information
t8m committed Dec 6, 2023
1 parent ccff907 commit 604eecf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crypto/encode_decode/decoder_pkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,9 @@ int ossl_decoder_cache_flush(OSSL_LIB_CTX *libctx)
DECODER_CACHE *cache
= ossl_lib_ctx_get_data(libctx, OSSL_LIB_CTX_DECODER_CACHE_INDEX);

if (cache == NULL) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
if (cache == NULL)
return 0;
}


if (!CRYPTO_THREAD_write_lock(cache->lock)) {
ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_OSSL_DECODER_LIB);
Expand Down

0 comments on commit 604eecf

Please sign in to comment.