From 293fb66d7f56897f587721254e47d855241d514d Mon Sep 17 00:00:00 2001 From: Justin Kerk Date: Sun, 31 Mar 2019 22:29:51 +0000 Subject: [PATCH] Prevent integer overflow in Z80 CTC device, which causes a runtime error on WebAssembly builds. [Justin Kerk] (nw) The issue was introduced in fc20d899ab83925a1169eeac2c61c70561b59ffb --- src/devices/machine/z80ctc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices/machine/z80ctc.cpp b/src/devices/machine/z80ctc.cpp index 74adf998feb..307da7d534a 100644 --- a/src/devices/machine/z80ctc.cpp +++ b/src/devices/machine/z80ctc.cpp @@ -373,7 +373,10 @@ u8 z80ctc_channel_device::read() LOG("CTC clock %f\n", period.as_hz()); - return u8((m_timer->remaining().as_double() / period.as_double()) + 1.0); + if(!m_timer->remaining().is_never()) + return u8((m_timer->remaining().as_double() / period.as_double()) + 1.0); + else + return 0; } }