(MESS) gb_lcd.c: Fixed sgb m_sgb_pal_map out of bound access. (nw)

This commit is contained in:
Wilbert Pol 2014-04-01 18:34:49 +00:00
parent c1b4dcf941
commit 35e6028a3f

View File

@ -1058,12 +1058,12 @@ void sgb_lcd_device::update_scanline()
data = tiles[tile_index] | (tiles[tile_index + 1] << 8);
data <<= m_layer[l].xshift;
/* Figure out which palette we're using */
assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < ARRAY_LENGTH(m_sgb_pal_map));
sgb_palette = m_sgb_pal_map[(m_end_x - i) >> 3][m_current_line >> 3] << 2;
while (i > 0)
{
/* Figure out which palette we're using */
assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < ARRAY_LENGTH(m_sgb_pal_map));
sgb_palette = m_sgb_pal_map[(m_end_x - i) >> 3][m_current_line >> 3] << 2;
while ((m_layer[l].xshift < 8) && i)
{
register int colour = ((data & 0x8000) ? 2 : 0) | ((data & 0x0080) ? 1 : 0);
@ -1088,8 +1088,6 @@ void sgb_lcd_device::update_scanline()
m_layer[l].xshift = 0;
tile_index = (map[m_layer[l].xindex] ^ m_gb_tile_no_mod) * 16;
data = tiles[tile_index] | (tiles[tile_index + 1] << 8);
assert(((m_end_x - i) >> 3) >= 0 && ((m_end_x - i) >> 3) < ARRAY_LENGTH(m_sgb_pal_map));
sgb_palette = m_sgb_pal_map[(m_end_x - i) >> 3][m_current_line >> 3] << 2;
}
}
l++;