Previous 15994 Revisions Next

r15161 Sunday 13th May, 2012 at 19:40:58 UTC by Firewave
fixed uninitialized field in ioport_field.m_chars (fixes stack corruption with three PORT_CHAR definitions) / added some sanity checks for PORT_CHAR adding and lookup
[src/emu]ioport.c

src/emu/ioport.c
r15160r15161
16601660   // reset sequences and chars
16611661   for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; seqtype++)
16621662      m_seq[seqtype].set_default();
1663   m_chars[0] = m_chars[1] = m_chars[2] = unicode_char(0);
1663   m_chars[0] = m_chars[1] = m_chars[2] = m_chars[3] = unicode_char(0);
16641664
16651665   // for DIP switches and configs, look for a default value from the owner
16661666   if (type == IPT_DIPSWITCH || type == IPT_CONFIG)
r15160r15161
18321832
18331833unicode_char ioport_field::keyboard_code(int which) const
18341834{
1835   unicode_char ch = m_chars[which];
1835   unicode_char ch;
1836   
1837   if (which >= ARRAY_LENGTH(m_chars))
1838      throw emu_fatalerror("Tried to access keyboard_code with out-of-range index %d\n", which);
1839   
1840   ch = m_chars[which];
18361841
18371842   // special hack to allow for PORT_CODE('\xA3')
18381843   if (ch >= 0xffffff80 && ch <= 0xffffffff)
r15160r15161
38423847      if (m_curfield->m_chars[index] == 0)
38433848      {
38443849         m_curfield->m_chars[index] = ch;
3845         break;
3850         return;
38463851      }
3852     
3853   throw emu_fatalerror("PORT_CHAR(%d) could not be added - maximum amount exceeded\n", ch);
38473854}
38483855
38493856

Previous 15994 Revisions Next


© 1998-2018 The MESS Team