Skip to content

Commit

Permalink
Fix memory leak of ctx_pool.contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
neverpanic committed Nov 22, 2024
1 parent cff4036 commit ee53c39
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 ee53c39

Please sign in to comment.