mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AU Host: Avoid potential UB reads of MIDI data
This commit is contained in:
parent
aebba3c875
commit
b5ea607dcc
1 changed files with 12 additions and 1 deletions
|
|
@ -1417,11 +1417,22 @@ public:
|
|||
for (const auto metadata : midiMessages)
|
||||
{
|
||||
if (metadata.numBytes <= 3)
|
||||
{
|
||||
const auto getByteOrZero = [&metadata] (int index)
|
||||
{
|
||||
return index < metadata.numBytes ? metadata.data[index] : (uint8) 0;
|
||||
};
|
||||
|
||||
MusicDeviceMIDIEvent (audioUnit,
|
||||
metadata.data[0], metadata.data[1], metadata.data[2],
|
||||
getByteOrZero (0),
|
||||
getByteOrZero (1),
|
||||
getByteOrZero (2),
|
||||
(UInt32) metadata.samplePosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
MusicDeviceSysEx (audioUnit, metadata.data, (UInt32) metadata.numBytes);
|
||||
}
|
||||
}
|
||||
|
||||
midiMessages.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue