]> granicus.if.org Git - libevent/commitdiff
Do not check O_NONBLOCK for invalid fds
authorAzat Khuzhin <azat@libevent.org>
Sun, 9 Dec 2018 11:48:44 +0000 (14:48 +0300)
committerAzat Khuzhin <azat@libevent.org>
Sun, 9 Dec 2018 11:48:44 +0000 (14:48 +0300)
Fixes: 6f988ee1 ("Merge branch 'check-O_NONBLOCK-in-debug'")
event.c

diff --git a/event.c b/event.c
index 4f4c9d771424498ac824cc15ff026c2286097646..3816650e6b73b14db8dfd10290c34c7d9e1d1c82 100644 (file)
--- a/event.c
+++ b/event.c
@@ -373,17 +373,18 @@ static void event_debug_assert_not_added_(const struct event *ev)
 }
 static void event_debug_assert_socket_nonblocking_(evutil_socket_t fd)
 {
-       int flags;
-
        if (!event_debug_mode_on_)
                return;
+       if (fd < 0)
+               return;
 
 #ifndef _WIN32
-       if ((flags = fcntl(fd, F_GETFL, NULL)) >= 0) {
-               EVUTIL_ASSERT(flags & O_NONBLOCK);
+       {
+               int flags;
+               if ((flags = fcntl(fd, F_GETFL, NULL)) >= 0) {
+                       EVUTIL_ASSERT(flags & O_NONBLOCK);
+               }
        }
-#else
-       (void)flags;
 #endif
 }
 #else