summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pstate.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-02-09 23:06:01 +0100
committer couriersud <couriersud@gmx.org>2019-02-09 23:07:27 +0100
commit83bd138bec869d9d3b78620d7de756763ca2b0cd (patch)
treef03db853d9c15c43327011be7ca78b94e4be128f /src/lib/netlist/plib/pstate.cpp
parent9d8cb783e3477927db622e0eef63c6e2c3e3ace7 (diff)
netlist: Fix crashes on certain hardware/library combos. (nw)
At least on macosx memory used by an object seems to be invalidated before the dtor is executed. This of course is deadly for child objects with references to the parent-in-deletion which may call back into the parent. One of the worst issues I had to fix. Ever. Lesson learnt: No tricks in dtors. Never.
Diffstat (limited to 'src/lib/netlist/plib/pstate.cpp')
-rw-r--r--src/lib/netlist/plib/pstate.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/netlist/plib/pstate.cpp b/src/lib/netlist/plib/pstate.cpp
index 14d0da3d374..3bd93ed4f8e 100644
--- a/src/lib/netlist/plib/pstate.cpp
+++ b/src/lib/netlist/plib/pstate.cpp
@@ -18,19 +18,19 @@ void state_manager_t::save_state_ptr(const void *owner, const pstring &stname, c
void state_manager_t::remove_save_items(const void *owner)
{
- for (auto i = m_save.begin(); i != m_save.end(); )
+ auto i = m_save.end();
+ while (i != m_save.begin())
{
+ i--;
if (i->get()->m_owner == owner)
i = m_save.erase(i);
- else
- i++;
}
- for (auto i = m_custom.begin(); i != m_custom.end(); )
+ i = m_custom.end();
+ while (i > m_custom.begin())
{
+ i--;
if (i->get()->m_owner == owner)
i = m_custom.erase(i);
- else
- i++;
}
}