summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/context.c6
-rw-r--r--doc/man3/OSSL_LIB_CTX.pod4
2 files changed, 7 insertions, 3 deletions
diff --git a/crypto/context.c b/crypto/context.c
index 6c088e6628..07fff535ff 100644
--- a/crypto/context.c
+++ b/crypto/context.c
@@ -204,9 +204,11 @@ OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx)
#ifndef FIPS_MODULE
OSSL_LIB_CTX *current_defctx;
- if ((current_defctx = get_default_context()) != NULL
- && set_default_context(libctx))
+ if ((current_defctx = get_default_context()) != NULL) {
+ if (libctx != NULL)
+ set_default_context(libctx);
return current_defctx;
+ }
#endif
return NULL;
diff --git a/doc/man3/OSSL_LIB_CTX.pod b/doc/man3/OSSL_LIB_CTX.pod
index 01b6a47b48..a23a10f5ce 100644
--- a/doc/man3/OSSL_LIB_CTX.pod
+++ b/doc/man3/OSSL_LIB_CTX.pod
@@ -41,7 +41,9 @@ default OpenSSL library context.
OSSL_LIB_CTX_set0_default() sets the default OpenSSL library context to be
I<ctx> in the current thread. The previous default library context is
returned. Care should be taken by the caller to restore the previous
-default library context with a subsequent call of this function.
+default library context with a subsequent call of this function. If I<ctx> is
+NULL then no change is made to the default library context, but a pointer to
+the current library context is still returned.
Care should be taken when changing the default library context and starting
async jobs (see L<ASYNC_start_job(3)>), as the default library context when