Skip to content

Commit

Permalink
async: fix cancel memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Feb 24, 2023
1 parent 5071947 commit 24746a1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/async/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ void re_async_cancel(struct re_async *async, intptr_t id)

mtx_lock(&async->mtx);

LIST_FOREACH(&async->workl, le)
le = list_head(&async->workl);
while(le)
{
struct async_work *w = le->data;
le = le->next;

if (w->id != id)
continue;
Expand All @@ -283,16 +285,19 @@ void re_async_cancel(struct re_async *async, intptr_t id)
list_move(&w->le, &async->freel);
}

LIST_FOREACH(&async->curl, le)
le = list_head(&async->curl);
while(le)
{
struct async_work *w = le->data;
le = le->next;

if (w->id != id)
continue;

w->workh = NULL;
w->cb = NULL;
w->arg = mem_deref(w->arg);
list_move(&w->le, &async->freel);
}

mtx_unlock(&async->mtx);
Expand Down

0 comments on commit 24746a1

Please sign in to comment.