Skip to content

Commit

Permalink
Fix memory leak of ctx_pool.contexts
Browse files Browse the repository at this point in the history
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2327985
Signed-off-by: Clemens Lang <cllang@redhat.com>
  • Loading branch information
neverpanic authored and simo5 committed Nov 22, 2024
1 parent cff4036 commit ffb4822
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ static void context_rm_pool(struct p11prov_ctx *ctx)
}
if (found) {
ctx_pool.num--;
if (ctx_pool.num == 0) {
/* This was the last context, free ctx_pool.contexts to avoid
* leaking memory. */
OPENSSL_free(ctx_pool.contexts);
ctx_pool.contexts = NULL;
}
} else {
P11PROV_debug("Context not found in pool ?!");
}
Expand Down

0 comments on commit ffb4822

Please sign in to comment.