Skip to content

Commit

Permalink
Fix a possible memory leak in make_receipt_request
Browse files Browse the repository at this point in the history
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 #22742)
  • Loading branch information
bernd-edlinger authored and t8m committed Dec 1, 2023
1 parent 49e9436 commit bed7a87
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,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)
Expand All @@ -1458,10 +1459,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;
}

Expand Down

0 comments on commit bed7a87

Please sign in to comment.