Skip to content

Commit 202488c

Browse files
MIDI: Assert if sysex message contains any status bytes
1 parent 5179690 commit 202488c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/juce_audio_basics/midi/juce_MidiMessage.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,12 +688,22 @@ bool MidiMessage::isSysEx() const noexcept
688688

689689
MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize)
690690
{
691+
jassert (sysexData != nullptr);
692+
jassert (dataSize > 0);
693+
691694
HeapBlock<uint8> m (dataSize + 2);
692695

693696
m[0] = 0xf0;
694697
memcpy (m + 1, sysexData, (size_t) dataSize);
695698
m[dataSize + 1] = 0xf7;
696699

700+
// The sysex data should not contain any header or tail status bytes, these
701+
// will be added automatically.
702+
#if JUCE_ASSERTIONS_ENABLED_OR_LOGGED
703+
for (auto i = 1; i < dataSize + 1; ++i)
704+
jassert (m[i] != 0xf0 && m[i] != 0xf7);
705+
#endif
706+
697707
return MidiMessage (m, dataSize + 2);
698708
}
699709

0 commit comments

Comments
 (0)