From 28402bb0af8d1ca1e1c6c9408ebe18738c19c0da Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 30 May 2021 00:33:25 +0800 Subject: Fix certain sysex messages causing crashes. --- core/qmpmidioutrtmidi.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/qmpmidioutrtmidi.cpp b/core/qmpmidioutrtmidi.cpp index f9fcab3..b677c9f 100644 --- a/core/qmpmidioutrtmidi.cpp +++ b/core/qmpmidioutrtmidi.cpp @@ -271,12 +271,14 @@ void qmpMidiOutRtMidi::extendedMessage(uint32_t length, const char *data) { fprintf(stderr, "Failed to send midi message: %s\n", e.what()); } - for (auto &msg : devinit->initseq.eventList) + if (!devinit) + return; + for (auto &imsg : devinit->initseq.eventList) { - if ((msg.type & 0xF0) == 0xF0 && msg.str == std::string(data, length)) + if ((imsg.type & 0xF0) == 0xF0 && imsg.str == std::string(data, length)) { - if (msg.time > 0) - std::this_thread::sleep_for(std::chrono::milliseconds(msg.time)); + if (imsg.time > 0) + std::this_thread::sleep_for(std::chrono::milliseconds(imsg.time)); } } } -- cgit v1.2.3