diff --git a/ChangeLog b/ChangeLog index fa0bcd6c..350dafb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2009-06-13 * Added support for $to_bytes + * Fix segfault due to bad checking of return values for inotify code + (sf.net #2804886) 2009-06-12 * Added support for per-task I/O statistics - $top_io diff --git a/src/conky.c b/src/conky.c index ae857779..fbfe76c9 100644 --- a/src/conky.c +++ b/src/conky.c @@ -6851,7 +6851,7 @@ static void main_loop(void) #endif double t; #ifdef HAVE_SYS_INOTIFY_H - int inotify_config_wd = 0; + int inotify_config_wd = -1; #define INOTIFY_EVENT_SIZE (sizeof(struct inotify_event)) #define INOTIFY_BUF_LEN (20 * (INOTIFY_EVENT_SIZE + 16)) char inotify_buff[INOTIFY_BUF_LEN]; @@ -7184,12 +7184,12 @@ static void main_loop(void) break; } #ifdef HAVE_SYS_INOTIFY_H - if (inotify_fd && !inotify_config_wd) { + if (inotify_fd != -1 && inotify_config_wd != -1) { inotify_config_wd = inotify_add_watch(inotify_fd, current_config, IN_MODIFY); } - if (inotify_fd && inotify_config_wd) { + if (inotify_fd != -1 && inotify_config_wd != -1) { int len = 0, idx = 0; fd_set descriptors; struct timeval time_to_wait; @@ -7232,7 +7232,7 @@ static void main_loop(void) } #ifdef HAVE_SYS_INOTIFY_H - if (inotify_fd) { + if (inotify_fd != -1) { inotify_rm_watch(inotify_fd, inotify_config_wd); close(inotify_fd); inotify_fd = inotify_config_wd = 0; diff --git a/src/llua.c b/src/llua.c index 10f0c845..1f5479f4 100644 --- a/src/llua.c +++ b/src/llua.c @@ -52,7 +52,7 @@ void llua_load(const char *script) ERR("llua_load: %s", lua_tostring(lua_L, -1)); lua_pop(lua_L, 1); #ifdef HAVE_SYS_INOTIFY_H - } else if (!llua_block_notify && inotify_fd) { + } else if (!llua_block_notify && inotify_fd != -1) { llua_append_notify(script); #endif /* HAVE_SYS_INOTIFY_H */ }