mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed a bug where a MidiMessage constructor could read beyond the end of the passed-in midi buffer if the midi message is non-standard
This commit is contained in:
parent
66365d55e2
commit
f312721cf9
1 changed files with 7 additions and 5 deletions
|
|
@ -225,7 +225,7 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
|
||||||
*dest = (uint8) byte;
|
*dest = (uint8) byte;
|
||||||
memcpy (dest + 1, src, (size_t) (size - 1));
|
memcpy (dest + 1, src, (size_t) (size - 1));
|
||||||
|
|
||||||
numBytesUsed += numVariableLengthSysexBytes; // (these aren't counted in the size)
|
numBytesUsed += (numVariableLengthSysexBytes + size); // (these aren't counted in the size)
|
||||||
}
|
}
|
||||||
else if (byte == 0xff)
|
else if (byte == 0xff)
|
||||||
{
|
{
|
||||||
|
|
@ -236,6 +236,8 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
|
||||||
uint8* dest = allocateSpace (size);
|
uint8* dest = allocateSpace (size);
|
||||||
*dest = (uint8) byte;
|
*dest = (uint8) byte;
|
||||||
memcpy (dest + 1, src, (size_t) size - 1);
|
memcpy (dest + 1, src, (size_t) size - 1);
|
||||||
|
|
||||||
|
numBytesUsed += size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -244,14 +246,14 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
|
||||||
|
|
||||||
if (size > 1)
|
if (size > 1)
|
||||||
{
|
{
|
||||||
packedData.asBytes[1] = src[0];
|
packedData.asBytes[1] = (sz > 0 ? src[0] : 0);
|
||||||
|
|
||||||
if (size > 2)
|
if (size > 2)
|
||||||
packedData.asBytes[2] = src[1];
|
packedData.asBytes[2] = (sz > 1 ? src[1] : 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
numBytesUsed += size;
|
numBytesUsed += jmin (size, sz + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue