diff --git a/src/ae_epoll.c b/src/ae_epoll.c index d48977b6..5680b6a2 100644 --- a/src/ae_epoll.c +++ b/src/ae_epoll.c @@ -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; } diff --git a/src/ae_kqueue.c b/src/ae_kqueue.c index 04c3536b..6bf64f4e 100644 --- a/src/ae_kqueue.c +++ b/src/ae_kqueue.c @@ -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;