Fix memory leak where fdlookup linked list is not freed during
ASYNC_WAIT_CTX_free Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
parent
7188f1f650
commit
55327ddfc1
@ -63,20 +63,22 @@ ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void)
|
|||||||
void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx)
|
void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx)
|
||||||
{
|
{
|
||||||
struct fd_lookup_st *curr;
|
struct fd_lookup_st *curr;
|
||||||
|
struct fd_lookup_st *next;
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
curr = ctx->fds;
|
curr = ctx->fds;
|
||||||
while (curr != NULL) {
|
while (curr != NULL) {
|
||||||
if (curr->del) {
|
if (!curr->del) {
|
||||||
/* This one has already been deleted so do nothing */
|
/* Only try and cleanup if it hasn't been marked deleted */
|
||||||
curr = curr->next;
|
if (curr->cleanup != NULL)
|
||||||
continue;
|
curr->cleanup(ctx, curr->key, curr->fd, curr->custom_data);
|
||||||
}
|
}
|
||||||
if (curr->cleanup != NULL)
|
/* Always free the fd_lookup_st */
|
||||||
curr->cleanup(ctx, curr->key, curr->fd, curr->custom_data);
|
next = curr->next;
|
||||||
curr = curr->next;
|
OPENSSL_free(curr);
|
||||||
|
curr = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
OPENSSL_free(ctx);
|
OPENSSL_free(ctx);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user