From: antirez Date: Wed, 7 Dec 2011 07:58:29 +0000 (+0100) Subject: Fixed a theoretical memory leak with no practical effects in ae_kqueue.c and ae_epoll... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/fb293ccbddb43f427ea1f791d8603fbd18e703e6 Fixed a theoretical memory leak with no practical effects in ae_kqueue.c and ae_epoll.c, thanks to magicyang87 for reporting it. --- 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;