Skip to content

Commit

Permalink
Fixed a theoretical memory leak with no practical effects in ae_kqueu…
Browse files Browse the repository at this point in the history
…e.c and ae_epoll.c, thanks to magicyang87 for reporting it.
  • Loading branch information
antirez committed Dec 7, 2011
1 parent 237194b commit fb293cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ae_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ static int aeApiCreate(aeEventLoop *eventLoop) {

if (!state) return -1;
state->epfd = epoll_create(1024); /* 1024 is just an hint for the kernel */
if (state->epfd == -1) return -1;
if (state->epfd == -1) {
zfree(state);
return -1;
}
eventLoop->apidata = state;
return 0;
}
Expand Down
5 changes: 4 additions & 1 deletion src/ae_kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ static int aeApiCreate(aeEventLoop *eventLoop) {

if (!state) return -1;
state->kqfd = kqueue();
if (state->kqfd == -1) return -1;
if (state->kqfd == -1) {
zfree(state);
return -1;
}
eventLoop->apidata = state;

return 0;
Expand Down

0 comments on commit fb293cc

Please sign in to comment.