From 9d509bd29c33a331cee2778c3a0bbf7d0d14c8dc Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Thu, 5 Jul 2018 13:13:00 +0200 Subject: Fix divtlb crash, nw --- src/emu/divtlb.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/emu/divtlb.cpp b/src/emu/divtlb.cpp index d6cc8b34e21..c227147cad9 100644 --- a/src/emu/divtlb.cpp +++ b/src/emu/divtlb.cpp @@ -179,10 +179,16 @@ bool device_vtlb_interface::vtlb_fill(offs_t address, int intention) { int liveindex = m_dynindex++ % m_dynamic; + // if an entry already exists at this index, free it - if (m_live[liveindex] != 0 && m_refcnt[m_live[liveindex] - 1] <= 1) - m_table[m_live[liveindex] - 1] = 0; - m_refcnt[m_live[liveindex] - 1]--; + if (m_live[liveindex] != 0) + { + if (m_refcnt[m_live[liveindex] - 1] <= 1) + m_table[m_live[liveindex] - 1] = 0; + else + m_refcnt[m_live[liveindex] - 1]--; + } + // claim this new entry m_live[liveindex] = tableindex + 1; -- cgit v1.2.3