]> granicus.if.org Git - libevent/commitdiff
Fix potential fd leak in listener_read_cb()
authorMark Ellzey <socket@gmail.com>
Tue, 28 Apr 2015 02:43:04 +0000 (22:43 -0400)
committerMark Ellzey <socket@gmail.com>
Tue, 28 Apr 2015 02:43:04 +0000 (22:43 -0400)
As pointed out by harlan_ in #libevent after running a coverity sweep.
If the listener is free'd, 'new_fd' is never closed.

listener.c

index 172d2927c0c3c70198538b2711fe9100be968d6f..2af14e3a7b54aad9cb037b29f7f95de7c142d9d9 100644 (file)
@@ -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;