Skip to content

Commit

Permalink
add_uris_recursive(): Avoid OSSL_STORE_INFO leak on error
Browse files Browse the repository at this point in the history
  • Loading branch information
t8m committed Jan 22, 2025
1 parent 7ffb656 commit c92adfc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ssl/ssl_cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,16 +993,17 @@ static int add_uris_recursive(STACK_OF(X509_NAME) *stack,
OSSL_STORE_CTX *ctx = NULL;
X509 *x = NULL;
X509_NAME *xn = NULL;
OSSL_STORE_INFO *info = NULL;

if ((ctx = OSSL_STORE_open(uri, NULL, NULL, NULL, NULL)) == NULL)
goto err;

while (!OSSL_STORE_eof(ctx) && !OSSL_STORE_error(ctx)) {
OSSL_STORE_INFO *info = OSSL_STORE_load(ctx);
int infotype = info == 0 ? 0 : OSSL_STORE_INFO_get_type(info);
int infotype;

if (info == NULL)
if ((info = OSSL_STORE_load(ctx) == NULL)
continue;
infotype = OSSL_STORE_INFO_get_type(info);

if (infotype == OSSL_STORE_INFO_NAME) {
/*
Expand All @@ -1027,13 +1028,15 @@ static int add_uris_recursive(STACK_OF(X509_NAME) *stack,
}

OSSL_STORE_INFO_free(info);
info = NULL;
}

ERR_clear_error();
goto done;

err:
ok = 0;
OSSL_STORE_INFO_free(info);
done:
OSSL_STORE_close(ctx);

Expand Down

0 comments on commit c92adfc

Please sign in to comment.