From d9eb2022ed4e732751589ac1d54f8cae19a6d364 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 13 Oct 2021 11:52:18 +0100 Subject: [PATCH] POSIX: Fix overflow when setting hi-res timer thread period on macOS/iOS --- modules/juce_core/native/juce_posix_SharedCode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h index 59f9a30eeb..f77928898e 100644 --- a/modules/juce_core/native/juce_posix_SharedCode.h +++ b/modules/juce_core/native/juce_posix_SharedCode.h @@ -1368,7 +1368,7 @@ private: mach_timebase_info (&timebase); const auto ticksPerMs = ((double) timebase.denom * 1000000.0) / (double) timebase.numer; - const auto periodTicks = (uint32_t) (ticksPerMs * periodMs); + const auto periodTicks = (uint32_t) jmin ((double) std::numeric_limits::max(), periodMs * ticksPerMs); thread_time_constraint_policy_data_t policy; policy.period = periodTicks;