mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed an invalid memory read when handling MIDI reset messages
This commit is contained in:
parent
93ea3d922f
commit
e1e3b42b4f
3 changed files with 32 additions and 18 deletions
|
|
@ -56,11 +56,18 @@ namespace MidiBufferHelpers
|
|||
size = (int) (d - data);
|
||||
}
|
||||
else if (byte == 0xff)
|
||||
{
|
||||
if (maxBytes == 1)
|
||||
{
|
||||
size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n;
|
||||
const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n);
|
||||
size = jmin (maxBytes, n + 2 + bytesLeft);
|
||||
}
|
||||
}
|
||||
else if (byte >= 0x80)
|
||||
{
|
||||
size = jmin (maxBytes, MidiMessage::getMessageLengthFromFirstByte ((uint8) byte));
|
||||
|
|
|
|||
|
|
@ -223,10 +223,17 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
|
|||
numBytesUsed += (numVariableLengthSysexBytes + size); // (these aren't counted in the size)
|
||||
}
|
||||
else if (byte == 0xff)
|
||||
{
|
||||
if (sz == 1)
|
||||
{
|
||||
size = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n;
|
||||
const int bytesLeft = readVariableLengthVal (src + 1, n);
|
||||
size = jmin (sz + 1, n + 2 + bytesLeft);
|
||||
}
|
||||
|
||||
auto dest = allocateSpace (size);
|
||||
*dest = (uint8) byte;
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ public:
|
|||
@param timeStamp the time to give the midi message - this value doesn't
|
||||
use any particular units, so will be application-specific
|
||||
@param sysexHasEmbeddedLength when reading sysexes, this flag indicates whether
|
||||
to expect the data to begin with a variable-length field
|
||||
indicating its size
|
||||
to expect the data to begin with a variable-length
|
||||
field indicating its size
|
||||
*/
|
||||
MidiMessage (const void* data, int maxBytesToUse,
|
||||
int& numBytesUsed, uint8 lastStatusByte,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue