Skip to content

Commit 30d5f28

Browse files
committed
opnmidi_midiplay.cpp: Fixed crash on active notes overflow
1 parent 7d78f59 commit 30d5f28

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/opnmidi_midiplay.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ bool OPNMIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocit
466466
if(isBlankNote)
467467
{
468468
// Don't even try to play the blank instrument! But, insert the dummy note.
469+
if(midiChan.activenotes.size() >= midiChan.activenotes.capacity())
470+
return false; // Overflow!
471+
469472
MIDIchannel::notes_iterator i = midiChan.ensure_create_activenote(note);
470473
MIDIchannel::NoteInfo &dummy = i->value;
471474
dummy.isBlank = true;
@@ -547,6 +550,9 @@ bool OPNMIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocit
547550
velocity = static_cast<uint8_t>(std::floor(static_cast<float>(velocity) * 0.8f));
548551

549552
// Allocate active note for MIDI channel
553+
if(midiChan.activenotes.size() >= midiChan.activenotes.capacity())
554+
return false; // Overflow!
555+
550556
MIDIchannel::notes_iterator ir = midiChan.ensure_create_activenote(note);
551557
MIDIchannel::NoteInfo &ni = ir->value;
552558
ni.vol = velocity;

0 commit comments

Comments
 (0)