From: <pa...@us...> - 2024-01-24 20:54:58
|
This is an automated email from the git hooks/post-receive-user script. pak21 pushed a commit to branch master in repository fuse. View the commit online: https://sourceforge.net/p/fuse-emulator/fuse/ci/03bee5e18f8cc1556d7bc527894f418e358433d0/ The following commit(s) were added to refs/heads/master by this push: new 03bee5e1 Cap tstates of timer event to (further) prevent segfault. 03bee5e1 is described below commit 03bee5e18f8cc1556d7bc527894f418e358433d0 Author: Philip Kendall <phi...@sh...> AuthorDate: Wed Jan 24 20:47:42 2024 +0000 Cap tstates of timer event to (further) prevent segfault. Additional fix for bug #504. --- ChangeLog | 2 ++ timer/timer.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0feb6c5b..d1afd9fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,8 @@ * Miscellaneous improvements: * Add ZIP files to the bash completion script (Alberto Garcia). + * Prevent potential segmentation fault due to overflow when emulation + speed is set very high (Pete Moore) 2021-02-27 Philip Kendall <phi...@sh...> diff --git a/timer/timer.c b/timer/timer.c index d7cafb1e..f0bf7bca 100644 --- a/timer/timer.c +++ b/timer/timer.c @@ -246,7 +246,13 @@ timer_frame( libspectrum_dword last_tstates, int event GCC_UNUSED, tstates = ( ( difference + TEN_MS / 1000.0 ) * machine_current->timings.processor_speed ) * speed + 0.5; - + + /* If speed is very large, tstates can also get very large; cap it to + avoid any potential overflows */ + if( tstates > 1 << 30 ) { + tstates = 1 << 30; + } + event_add( last_tstates + tstates, timer_event ); start_time = current_time + TEN_MS / 1000.0; |