diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2023-11-15 19:31:28 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-12-01 11:06:34 +0100 |
commit | 4ffa17248736300dcbca58ba57aa0badac80c388 (patch) | |
tree | abaefa4b0146de0dccd34501d4aec8ce17b79a23 /apps | |
parent | c24cb3f5bcec41284419812272dd6be2a0294683 (diff) |
Fix a possible memory leak in make_receipt_request
When the CMS_ReceiptRequest cannot be created,
the rct_to and rct_from may be leaked.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22742)
(cherry picked from commit bed7a878107818c297301c6602013d364b266c67)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/cms.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/apps/cms.c b/apps/cms.c index 0d1730c56f..12095b9641 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -1413,6 +1413,7 @@ static CMS_ReceiptRequest STACK_OF(OPENSSL_STRING) *rr_from) { STACK_OF(GENERAL_NAMES) *rct_to = NULL, *rct_from = NULL; + CMS_ReceiptRequest *rr; rct_to = make_names_stack(rr_to); if (rct_to == NULL) @@ -1424,10 +1425,14 @@ static CMS_ReceiptRequest } else { rct_from = NULL; } - return CMS_ReceiptRequest_create0_ex(NULL, -1, rr_allorfirst, rct_from, - rct_to, app_get0_libctx()); + rr = CMS_ReceiptRequest_create0_ex(NULL, -1, rr_allorfirst, rct_from, + rct_to, app_get0_libctx()); + if (rr == NULL) + goto err; + return rr; err: sk_GENERAL_NAMES_pop_free(rct_to, GENERAL_NAMES_free); + sk_GENERAL_NAMES_pop_free(rct_from, GENERAL_NAMES_free); return NULL; } |