Skip potential garbage midi-step

This commit is contained in:
Robin Gareus 2019-08-20 04:38:59 +02:00
parent 114b5088c7
commit 0972e9a513
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -193,7 +193,9 @@ StepEditor::check_step_edit ()
Evoral::EventType type; Evoral::EventType type;
uint32_t size; uint32_t size;
incoming.read_prefix (&time, &type, &size); if (!incoming.read_prefix (&time, &type, &size)) {
break;
}
if (size > bufsize) { if (size > bufsize) {
delete [] buf; delete [] buf;
@ -201,9 +203,11 @@ StepEditor::check_step_edit ()
buf = new uint8_t[bufsize]; buf = new uint8_t[bufsize];
} }
incoming.read_contents (size, buf); if (!incoming.read_contents (size, buf)) {
break;
}
if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON) { if ((buf[0] & 0xf0) == MIDI_CMD_NOTE_ON && size == 3) {
step_add_note (buf[0] & 0xf, buf[1], buf[2], Temporal::Beats()); step_add_note (buf[0] & 0xf, buf[1], buf[2], Temporal::Beats());
} }
} }