From ef0ae0c73687e804fe86854af3c36f9d3f90fcf8 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 25 Feb 2010 14:50:55 +0000 Subject: luaevent.c: Fix potential overflow in converting seconds to timeval --- src/luaevent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/luaevent.c b/src/luaevent.c index 6036cf1..89c295a 100644 --- a/src/luaevent.c +++ b/src/luaevent.c @@ -56,8 +56,8 @@ int getSocketFd(lua_State* L, int idx) { } void load_timeval(double time, struct timeval *tv) { - tv->tv_sec = (int)time; - tv->tv_usec = (int)(time * 1000000) % 1000000; + tv->tv_sec = (int) time; + tv->tv_usec = (int)( (time - tv->tv_sec) * 1000000 ); } /* sock, event, callback, timeout */ -- cgit v1.2.3