[core] fix timer overflow on 32bit systems (#16)

must cast ts.tv_sec to 64bits before we multiply it to prevent 32bit math and overflow
This commit is contained in:
Spencer Sevilla 2022-08-01 15:44:04 -07:00 committed by Sukchan Lee
parent 724fa56843
commit 0759c2da5a
1 changed files with 1 additions and 1 deletions

View File

@ -242,7 +242,7 @@ ogs_time_t ogs_get_monotonic_time(void)
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ((ts.tv_sec * 1000000UL) + (ts.tv_nsec / 1000UL));
return (((int64_t) ts.tv_sec * 1000000UL) + (ts.tv_nsec / 1000UL));
#elif defined(__APPLE__)
static mach_timebase_info_data_t info = {0};
static double ratio = 0.0;