From fb293ccbddb43f427ea1f791d8603fbd18e703e6 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 7 Dec 2011 08:58:29 +0100 Subject: [PATCH] Fixed a theoretical memory leak with no practical effects in ae_kqueue.c and ae_epoll.c, thanks to magicyang87 for reporting it. --- src/ae_epoll.c | 5 ++++- src/ae_kqueue.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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;