summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2012-02-18 14:09:09 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2012-02-18 14:09:09 +0000
commit287777d6a134a49403d82e91c52535bc52dacb6e (patch)
tree7d73ee3d0adaea00ae7370a953f65692becb95ae
parent07077bc4250e11755701759b2f65f9318049a559 (diff)
Delete dynamic_array buffer only if allocated, fixes crash in taitogn, require at least clean lib compile (no whatsnew)
-rw-r--r--src/lib/util/coretmpl.h4
-rw-r--r--src/mame/drivers/taitogn.c8
2 files changed, 6 insertions, 6 deletions
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<taitogn_state>();
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