From a4f4fc50b9e1c825806dc7dc44ac8eb4398a3a5b Mon Sep 17 00:00:00 2001 From: PHO Date: Mon, 26 Jan 2015 14:54:16 +0900 Subject: [PATCH 1/3] Avoid integer overflow in MonotonicClock{S,MS,US} This is Darwin specific: the previous implementation was causing an integer overflow when base.numer is very large. On PPC Darwin, the timebase info is 1000000000/33330116 and this is too large for integer arithmetic. --- NEWS | 1 + src/system/Clock.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index e7a80b964..9cd558070 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ver 0.18.23 (not yet released) * despotify: remove defunct plugin +* fix clock integer overflow on OS X * fix gcc 5.0 warnings ver 0.18.22 (2014/01/14) diff --git a/src/system/Clock.cxx b/src/system/Clock.cxx index 347997a44..916bda56c 100644 --- a/src/system/Clock.cxx +++ b/src/system/Clock.cxx @@ -40,8 +40,8 @@ MonotonicClockMS(void) if (base.denom == 0) (void)mach_timebase_info(&base); - return (unsigned)((mach_absolute_time() * base.numer) - / (1000000 * base.denom)); + return (unsigned)(((double)mach_absolute_time() * base.numer) + / base.denom / 1000000); #elif defined(CLOCK_MONOTONIC) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -82,8 +82,8 @@ MonotonicClockUS(void) if (base.denom == 0) (void)mach_timebase_info(&base); - return ((uint64_t)mach_absolute_time() * (uint64_t)base.numer) - / (1000 * (uint64_t)base.denom); + return (uint64_t)(((double)mach_absolute_time() * base.numer) + / base.denom / 1000); #elif defined(CLOCK_MONOTONIC) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); From 5489dec28d77f9339b0372100a4838f66e35dfd5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 1 Feb 2015 12:22:17 +0100 Subject: [PATCH 2/3] NEWS: fix v0.18.22 release date --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9cd558070..8d8493ae1 100644 --- a/NEWS +++ b/NEWS @@ -3,7 +3,7 @@ ver 0.18.23 (not yet released) * fix clock integer overflow on OS X * fix gcc 5.0 warnings -ver 0.18.22 (2014/01/14) +ver 0.18.22 (2015/01/14) * fix clang 3.6 warnings ver 0.18.21 (2014/12/17) From 4a5528697dce85d1fd30d0c9640f1adb791d0a8b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 6 Feb 2015 17:04:14 +0100 Subject: [PATCH 3/3] release v0.18.23 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8d8493ae1..5eb98cb49 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ver 0.18.23 (not yet released) +ver 0.18.23 (2015/02/06) * despotify: remove defunct plugin * fix clock integer overflow on OS X * fix gcc 5.0 warnings