From 8270fc29f3964f96d7029d5c3dcebe5be8bb5bff Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 5 Aug 2013 11:24:11 +0100 Subject: [PATCH] ecore_main_fd_handler_fd_get can return -1 so check fd validity before calling read() with potentially -1. Signed-off-by: Chris Michael --- src/lib/eio/eio_monitor_inotify.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/eio/eio_monitor_inotify.c b/src/lib/eio/eio_monitor_inotify.c index 6fb6b0844d..5ad5e79d29 100644 --- a/src/lib/eio/eio_monitor_inotify.c +++ b/src/lib/eio/eio_monitor_inotify.c @@ -123,11 +123,14 @@ _eio_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh) Eio_Monitor_Backend *backend; unsigned char buffer[16384]; struct inotify_event *event; - int i = 0; + int i = 0, fd; int event_size; ssize_t size; - size = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof(buffer)); + fd = ecore_main_fd_handler_fd_get(fdh); + if (fd < 0) return ECORE_CALLBACK_RENEW; + + size = read(fd, buffer, sizeof(buffer)); while (i < size) { event = (struct inotify_event *)&buffer[i];