Skip to content

Commit

Permalink
Fix poller memleak when malloc failed. (#1661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim authored Nov 24, 2024
1 parent dd95599 commit 05168d9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/kernel/poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,17 +1332,20 @@ static struct __poller_node *__poller_new_node(const struct poller_data *data,
}

node = (struct __poller_node *)malloc(sizeof (struct __poller_node));
if (node)
if (!node)
{
node->data = *data;
node->event = event;
node->in_rbtree = 0;
node->removed = 0;
node->res = res;
if (timeout >= 0)
__poller_node_set_timeout(timeout, node);
free(res);
return NULL;
}

node->data = *data;
node->event = event;
node->in_rbtree = 0;
node->removed = 0;
node->res = res;
if (timeout >= 0)
__poller_node_set_timeout(timeout, node);

return node;
}

Expand Down

0 comments on commit 05168d9

Please sign in to comment.