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 5083126
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/async/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,12 @@ 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 5083126

Please sign in to comment.