From 3395853ba2209dd2f4d812d6b2367320c6057667 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 9 Mar 2024 01:29:50 +1000 Subject: [PATCH] CDROM: Fix overflow in UpdatePositionWhileSeeking() --- src/core/cdrom.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 102d9d64c..20b02c01c 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -2406,8 +2406,9 @@ void CDROM::UpdatePositionWhileSeeking() { DebugAssert(IsSeeking()); - const float completed_frac = 1.0f - (static_cast(s_drive_event->GetTicksUntilNextExecution()) / - static_cast(s_drive_event->GetInterval())); + const float completed_frac = 1.0f - std::min(static_cast(s_drive_event->GetTicksUntilNextExecution()) / + static_cast(s_drive_event->GetInterval()), + 1.0f); CDImage::LBA current_lba; if (s_seek_end_lba > s_seek_start_lba)