summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2024-04-11 10:05:04 +0200
committerTomas Mraz <tomas@openssl.org>2024-05-10 13:51:55 +0200
commit2a5d733e64f009f758163da852f1e7fee6aea0a2 (patch)
treed6149a2285ef8db187f1a3ba5104b14c370ccf7c /test
parent4a5088259e78127354f497931568de409ac905fc (diff)
tls_provider_init(): Fix leaks in error cases
Fixes #24101 Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Paul Dale <ppzgs1@gmail.com> (Merged from https://github.com/openssl/openssl/pull/24103)
Diffstat (limited to 'test')
-rw-r--r--test/tls-provider.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/tls-provider.c b/test/tls-provider.c
index c5b2306729..18c5960a4c 100644
--- a/test/tls-provider.c
+++ b/test/tls-provider.c
@@ -3223,7 +3223,7 @@ int tls_provider_init(const OSSL_CORE_HANDLE *handle,
PROV_XOR_CTX *prov_ctx = xor_newprovctx(libctx);
if (libctx == NULL || prov_ctx == NULL)
- return 0;
+ goto err;
*provctx = prov_ctx;
@@ -3258,23 +3258,29 @@ int tls_provider_init(const OSSL_CORE_HANDLE *handle,
*/
if (!c_obj_create(handle, XORSIGALG_OID, XORSIGALG_NAME, XORSIGALG_NAME)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
- return 0;
+ goto err;
}
if (!c_obj_add_sigid(handle, XORSIGALG_OID, "", XORSIGALG_OID)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
- return 0;
+ goto err;
}
if (!c_obj_create(handle, XORSIGALG_HASH_OID, XORSIGALG_HASH_NAME, NULL)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
- return 0;
+ goto err;
}
if (!c_obj_add_sigid(handle, XORSIGALG_HASH_OID, XORSIGALG_HASH, XORSIGALG_HASH_OID)) {
ERR_raise(ERR_LIB_USER, XORPROV_R_OBJ_CREATE_ERR);
- return 0;
+ goto err;
}
*out = tls_prov_dispatch_table;
return 1;
+
+err:
+ OPENSSL_free(prov_ctx);
+ *provctx = NULL;
+ OSSL_LIB_CTX_free(libctx);
+ return 0;
}