Fixed a theoretical memory leak with no practical effects in ae_kqueue.c and ae_epoll.c, thanks to magicyang87 for reporting it.

This commit is contained in:
antirez 2011-12-07 08:58:29 +01:00
parent 237194b760
commit fb293ccbdd
2 changed files with 8 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;