mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +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)
|
for (const auto metadata : midiMessages)
|
||||||
{
|
{
|
||||||
if (metadata.numBytes <= 3)
|
if (metadata.numBytes <= 3)
|
||||||
|
{
|
||||||
|
const auto getByteOrZero = [&metadata] (int index)
|
||||||
|
{
|
||||||
|
return index < metadata.numBytes ? metadata.data[index] : (uint8) 0;
|
||||||
|
};
|
||||||
|
|
||||||
MusicDeviceMIDIEvent (audioUnit,
|
MusicDeviceMIDIEvent (audioUnit,
|
||||||
metadata.data[0], metadata.data[1], metadata.data[2],
|
getByteOrZero (0),
|
||||||
|
getByteOrZero (1),
|
||||||
|
getByteOrZero (2),
|
||||||
(UInt32) metadata.samplePosition);
|
(UInt32) metadata.samplePosition);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
MusicDeviceSysEx (audioUnit, metadata.data, (UInt32) metadata.numBytes);
|
MusicDeviceSysEx (audioUnit, metadata.data, (UInt32) metadata.numBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
midiMessages.clear();
|
midiMessages.clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue