From 86392455338e5e1fc65b25a3136d866228e28e40 Mon Sep 17 00:00:00 2001 From: Mary Date: Thu, 5 Jan 2023 01:55:27 +0100 Subject: [PATCH] hle: Add safety measure around overflow in ScheduleFutureInvocation Fix crash on Linux since 08831eecf77cedd3c4192ebab5a9c485fb15d51e. --- Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs b/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs index 4eb736f2..020048f4 100644 --- a/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs +++ b/Ryujinx.HLE/HOS/Kernel/Common/KTimeManager.cs @@ -44,7 +44,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Common public void ScheduleFutureInvocation(IKFutureSchedulerObject schedulerObj, long timeout) { - long timePoint = PerformanceCounter.ElapsedTicks + ConvertNanosecondsToHostTicks(timeout); + long startTime = PerformanceCounter.ElapsedTicks; + long timePoint = startTime + ConvertNanosecondsToHostTicks(timeout); + + if (timePoint < startTime) + { + timePoint = long.MaxValue; + } lock (_context.CriticalSection.Lock) {