From 0972e9a513abaff87d24880691f22fc9505060c6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 20 Aug 2019 04:38:59 +0200 Subject: Skip potential garbage midi-step --- gtk2_ardour/step_editor.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/step_editor.cc b/gtk2_ardour/step_editor.cc index dcb5376003..e2b230de27 100644 --- a/gtk2_ardour/step_editor.cc +++ b/gtk2_ardour/step_editor.cc @@ -193,7 +193,9 @@ StepEditor::check_step_edit () Evoral::EventType type; uint32_t size; - incoming.read_prefix (&time, &type, &size); + if (!incoming.read_prefix (&time, &type, &size)) { + break; + } if (size > bufsize) { delete [] buf; @@ -201,9 +203,11 @@ StepEditor::check_step_edit () 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()); } } -- cgit v1.2.3