dimemory: Reimplement aa0d17757d9e5857bb99887841133045cc530655 correctly; reading past the end of a std::vector is not a good thing to do (nw)

This commit is contained in:
AJR 2018-11-26 20:57:45 -05:00 committed by Vas Crabb
parent 296c24d3d7
commit b4e395e74e

View File

@ -94,7 +94,8 @@ void device_memory_interface::interface_config_complete()
void device_memory_interface::interface_validity_check(validity_checker &valid) const
{
// loop over all address spaces
for (int spacenum = 0; spacenum < int(m_address_map.size()); ++spacenum)
const int max_spaces = std::max(m_address_map.size(), m_address_config.size());
for (int spacenum = 0; spacenum < max_spaces; ++spacenum)
{
if (space_config(spacenum))
{
@ -104,7 +105,7 @@ void device_memory_interface::interface_validity_check(validity_checker &valid)
// let the map check itself
addrmap.map_validity_check(valid, spacenum);
}
else if (!m_address_map[spacenum].isnull())
else if (spacenum < int(m_address_map.size()) && !m_address_map[spacenum].isnull())
osd_printf_warning("Map configured for nonexistent memory space %d\n", spacenum);
}
}