From a0f1d97c2b4b305761db5e488c04153b8a80ebfa Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 30 Dec 2016 23:28:58 +0100 Subject: [PATCH] fix(controller): UB sanitizer patch --- src/components/controller.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 75e71306..93e65188 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -279,14 +279,14 @@ void controller::read_events() { } // Process event on the config inotify watch fd - if (fd_confwatch && FD_ISSET(fd_confwatch, &readfds) && m_confwatch->await_match()) { + if (fd_confwatch > -1 && FD_ISSET(fd_confwatch, &readfds) && m_confwatch->await_match()) { m_log.info("Configuration file changed"); g_terminate = 1; g_reload = 1; } // Process event on the xcb connection fd - if (fd_connection && FD_ISSET(fd_connection, &readfds)) { + if (fd_connection > -1 && FD_ISSET(fd_connection, &readfds)) { shared_ptr evt{}; while ((evt = shared_ptr(xcb_poll_for_event(m_connection), free)) != nullptr) { try { @@ -300,7 +300,7 @@ void controller::read_events() { } // Process event on the ipc fd - if (fd_ipc && FD_ISSET(fd_ipc, &readfds)) { + if (fd_ipc > -1 && FD_ISSET(fd_ipc, &readfds)) { m_ipc->receive_message(); fds.erase(std::remove_if(fds.begin(), fds.end(), [fd_ipc](int fd) { return fd == fd_ipc; }), fds.end()); fds.emplace_back((fd_ipc = m_ipc->get_file_descriptor()));