From: Mark Ellzey Date: Tue, 28 Apr 2015 02:43:04 +0000 (-0400) Subject: Fix potential fd leak in listener_read_cb() X-Git-Tag: release-2.1.6-beta~90^2~92 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a695a720cda892c270736d127333d73553842094;p=libevent Fix potential fd leak in listener_read_cb() As pointed out by harlan_ in #libevent after running a coverity sweep. If the listener is free'd, 'new_fd' is never closed. --- diff --git a/listener.c b/listener.c index 172d2927..2af14e3a 100644 --- a/listener.c +++ b/listener.c @@ -421,6 +421,8 @@ listener_read_cb(evutil_socket_t fd, short what, void *p) if (lev->refcnt == 1) { int freed = listener_decref_and_unlock(lev); EVUTIL_ASSERT(freed); + + evutil_closesocket(new_fd); return; } --lev->refcnt;