diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index 59e012fe753..db1d6c1e930 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -76,7 +76,7 @@ public: // helpers void append(const _ElementType &element) { if (m_count == m_allocated) expand_internal((m_allocated == 0) ? 16 : (m_allocated << 1), true); m_array[m_count++] = element; } - void reset() { delete[] m_array; m_array = NULL; m_count = m_allocated = 0; } + void reset() { if (m_array) delete[] m_array; m_array = NULL; m_count = m_allocated = 0; } void resize(int count, bool keepdata = false) { if (count > m_allocated) expand_internal(count, keepdata); m_count = count; } private: @@ -89,7 +89,7 @@ private: if (keepdata) for (int index = 0; index < m_count; index++) newarray[index] = m_array[index]; - delete[] m_array; + if (m_array) delete[] m_array; m_array = newarray; } diff --git a/src/mame/drivers/taitogn.c b/src/mame/drivers/taitogn.c index 48f0f7a944e..e5b72ddb8de 100644 --- a/src/mame/drivers/taitogn.c +++ b/src/mame/drivers/taitogn.c @@ -357,8 +357,6 @@ public: UINT32 m_coin_info; UINT32 m_mux_data; - - dynamic_buffer m_key; }; @@ -453,6 +451,8 @@ static WRITE32_HANDLER(rf5c296_mem_w) taitogn_state *state = space->machine().driver_data(); if(offset >= 0x140 && offset <= 0x144) { + dynamic_buffer key; + int pos = (offset - 0x140)*2; UINT8 v, k; if(ACCESSING_BITS_16_23) { @@ -460,8 +460,8 @@ static WRITE32_HANDLER(rf5c296_mem_w) pos++; } else v = data; - get_disk_handle(space->machine(), ":drive_0")->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, state->m_key); - k = pos < state->m_key.count() ? state->m_key[pos] : 0; + get_disk_handle(space->machine(), ":drive_0")->read_metadata(HARD_DISK_KEY_METADATA_TAG, 0, key); + k = pos < key.count() ? key[pos] : 0; if(v == k) state->m_locked &= ~(1 << pos); else