summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Oliver Stöneberg <firewave@users.noreply.github.com>2018-01-06 10:52:45 +0100
committer Vas Crabb <cuavas@users.noreply.github.com>2018-01-06 20:52:45 +1100
commitb2ac68ec1c4d2fff7b21faf1021a7b36813788ac (patch)
treef6aad83a2b9d4c2604921350c029457ab694a161
parenteab5e7e1163caa1c3ba806e870ceccedb871702d (diff)
Added asserts for index out of bounds (#3017)
* acia.cpp: added asserts for index out of bounds with e.g. mushi2k4 ../../../../../src/devices/sound/aica.cpp:996:40: runtime error: index 130 out of bounds for type 'uint16_t [128]' ../../../../../src/devices/sound/aica.cpp:916:37: runtime error: index 130 out of bounds for type 'uint16_t [128]' ../../../../../src/devices/sound/aica.cpp:978:42: runtime error: index 224 out of bounds for type 'uint8_t [192]' * k054156_k054157_k056832.cpp: added assert for index out of bounds with ddboy (nw) ../../../../../src/mame/video/k054156_k054157_k056832.cpp:1152:2: runtime error: index 5 out of bounds for type 'uint16_t [4]' ../../../../../src/mame/video/k054156_k054157_k056832.cpp:1152:2: runtime error: index 5 out of bounds for type 'uint16_t [4]' * vis.cpp: added assert for index out of bounds with vis (nw) ../../../../../src/mame/drivers/vis.cpp:538:4: runtime error: index 49 out of bounds for type 'uint8_t [49]' * hp1ll3.cpp: added assert for index out of bounds with hp_ipc (nw) ../../../../../src/devices/video/hp1ll3.cpp:557:5: runtime error: index 11 out of bounds for type 'uint16_t [11]' ../../../../../src/devices/video/hp1ll3.cpp:555:5: runtime error: index 11 out of bounds for type 'uint16_t [11]'
-rw-r--r--src/devices/sound/aica.cpp7
-rw-r--r--src/devices/video/hp1ll3.cpp1
-rw-r--r--src/mame/drivers/vis.cpp1
-rw-r--r--src/mame/video/k054156_k054157_k056832.cpp1
4 files changed, 10 insertions, 0 deletions
diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp
index f636f209576..24b114719f7 100644
--- a/src/devices/sound/aica.cpp
+++ b/src/devices/sound/aica.cpp
@@ -913,7 +913,10 @@ void aica_device::w16(address_space &space,unsigned int addr,unsigned short val)
if(addr<0x3200) //COEF
*((unsigned short *) (m_DSP.COEF+(addr-0x3000)/2))=val;
else if(addr<0x3400)
+ {
+ assert(((addr-0x3200)/2) < ARRAY_LENGTH(m_DSP.MADRS));
*((unsigned short *) (m_DSP.MADRS+(addr-0x3200)/2))=val;
+ }
else if(addr<0x3c00)
{
*((unsigned short *) (m_DSP.MPRO+(addr-0x3400)/2))=val;
@@ -975,6 +978,7 @@ unsigned short aica_device::r16(address_space &space, unsigned int addr)
else if (addr < 0x28be)
{
UpdateRegR(space, addr&0xff);
+ assert((addr&0xff) < ARRAY_LENGTH(m_udata.datab));
v= *((unsigned short *) (m_udata.datab+((addr&0xff))));
if((addr&0xfffe)==0x2810) m_udata.data[0x10/2] &= 0x7FFF; // reset LP on read
}
@@ -993,7 +997,10 @@ unsigned short aica_device::r16(address_space &space, unsigned int addr)
if(addr<0x3200) //COEF
v= *((unsigned short *) (m_DSP.COEF+(addr-0x3000)/2));
else if(addr<0x3400)
+ {
+ assert(((addr-0x3200)/2) < ARRAY_LENGTH(m_DSP.MADRS));
v= *((unsigned short *) (m_DSP.MADRS+(addr-0x3200)/2));
+ }
else if(addr<0x3c00)
v= *((unsigned short *) (m_DSP.MPRO+(addr-0x3400)/2));
else if(addr<0x4000)
diff --git a/src/devices/video/hp1ll3.cpp b/src/devices/video/hp1ll3.cpp
index ada8f48404d..dc6164cbbc2 100644
--- a/src/devices/video/hp1ll3.cpp
+++ b/src/devices/video/hp1ll3.cpp
@@ -551,6 +551,7 @@ WRITE8_MEMBER( hp1ll3_device::write )
switch (m_command)
{
case CONF:
+ assert((m_conf_ptr >> 1) < ARRAY_LENGTH(m_conf));
if (m_conf_ptr & 1) {
m_conf[m_conf_ptr >> 1] |= data;
} else {
diff --git a/src/mame/drivers/vis.cpp b/src/mame/drivers/vis.cpp
index 5a8399db147..f4fb764b02f 100644
--- a/src/mame/drivers/vis.cpp
+++ b/src/mame/drivers/vis.cpp
@@ -535,6 +535,7 @@ WRITE8_MEMBER(vis_vga_device::vga_w)
break;
case 0x05:
case 0x25:
+ assert(vga.crtc.index < ARRAY_LENGTH(m_crtc_regs));
m_crtc_regs[vga.crtc.index] = data;
switch(vga.crtc.index)
{
diff --git a/src/mame/video/k054156_k054157_k056832.cpp b/src/mame/video/k054156_k054157_k056832.cpp
index ef56418616d..9bde7c4f214 100644
--- a/src/mame/video/k054156_k054157_k056832.cpp
+++ b/src/mame/video/k054156_k054157_k056832.cpp
@@ -1149,6 +1149,7 @@ WRITE32_MEMBER( k056832_device::long_w )
WRITE16_MEMBER( k056832_device::b_word_w )
{
+ assert(offset < ARRAY_LENGTH(m_regsb));
COMBINE_DATA(&m_regsb[offset]);
}