Change the semantics of OSSL_LIB_CTX_set0_default() NULL handling
authorMatt Caswell <matt@openssl.org>
Thu, 15 Apr 2021 15:46:35 +0000 (16:46 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 19 Apr 2021 09:50:29 +0000 (10:50 +0100)
commit92b20fb8f742d50ca9eae8c28a855df94b9a3783
tree8abd7f8e09d25bb6c51d0efd1febe6a5d581a82f
parent145a4c871d9632a6eb2145f8a2b417bec58e7ee5
Change the semantics of OSSL_LIB_CTX_set0_default() NULL handling

Change things so that passing NULL to OSSL_LIB_CTX_set0_default() means
keep the current library context unchanged.

This has the advantage of simplifying error handling, e.g. you can call
OSSL_LIB_CTX_set0_default in an error/finalisation block safe in the
knowledge the if the "prevctx" was never set then it will be a no-op (like
calling a "free" function with NULL).

Fixes #14593

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14890)
crypto/context.c
doc/man3/OSSL_LIB_CTX.pod