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
|
|
@ -57,9 +57,16 @@ namespace MidiBufferHelpers
|
||||||
}
|
}
|
||||||
else if (byte == 0xff)
|
else if (byte == 0xff)
|
||||||
{
|
{
|
||||||
int n;
|
if (maxBytes == 1)
|
||||||
const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n);
|
{
|
||||||
size = jmin (maxBytes, n + 2 + bytesLeft);
|
size = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
const int bytesLeft = MidiMessage::readVariableLengthVal (data + 1, n);
|
||||||
|
size = jmin (maxBytes, n + 2 + bytesLeft);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (byte >= 0x80)
|
else if (byte >= 0x80)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -224,9 +224,16 @@ MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const
|
||||||
}
|
}
|
||||||
else if (byte == 0xff)
|
else if (byte == 0xff)
|
||||||
{
|
{
|
||||||
int n;
|
if (sz == 1)
|
||||||
const int bytesLeft = readVariableLengthVal (src + 1, n);
|
{
|
||||||
size = jmin (sz + 1, n + 2 + bytesLeft);
|
size = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
const int bytesLeft = readVariableLengthVal (src + 1, n);
|
||||||
|
size = jmin (sz + 1, n + 2 + bytesLeft);
|
||||||
|
}
|
||||||
|
|
||||||
auto dest = allocateSpace (size);
|
auto dest = allocateSpace (size);
|
||||||
*dest = (uint8) byte;
|
*dest = (uint8) byte;
|
||||||
|
|
|
||||||
|
|
@ -83,19 +83,19 @@ public:
|
||||||
complete message, and will return the number of bytes it used. This lets
|
complete message, and will return the number of bytes it used. This lets
|
||||||
you read a sequence of midi messages from a file or stream.
|
you read a sequence of midi messages from a file or stream.
|
||||||
|
|
||||||
@param data the data to read from
|
@param data the data to read from
|
||||||
@param maxBytesToUse the maximum number of bytes it's allowed to read
|
@param maxBytesToUse the maximum number of bytes it's allowed to read
|
||||||
@param numBytesUsed returns the number of bytes that were actually needed
|
@param numBytesUsed returns the number of bytes that were actually needed
|
||||||
@param lastStatusByte in a sequence of midi messages, the initial byte
|
@param lastStatusByte in a sequence of midi messages, the initial byte
|
||||||
can be dropped from a message if it's the same as the
|
can be dropped from a message if it's the same as the
|
||||||
first byte of the previous message, so this lets you
|
first byte of the previous message, so this lets you
|
||||||
supply the byte to use if the first byte of the message
|
supply the byte to use if the first byte of the message
|
||||||
has in fact been dropped.
|
has in fact been dropped.
|
||||||
@param timeStamp the time to give the midi message - this value doesn't
|
@param timeStamp the time to give the midi message - this value doesn't
|
||||||
use any particular units, so will be application-specific
|
use any particular units, so will be application-specific
|
||||||
@param sysexHasEmbeddedLength when reading sysexes, this flag indicates whether
|
@param sysexHasEmbeddedLength when reading sysexes, this flag indicates whether
|
||||||
to expect the data to begin with a variable-length field
|
to expect the data to begin with a variable-length
|
||||||
indicating its size
|
field indicating its size
|
||||||
*/
|
*/
|
||||||
MidiMessage (const void* data, int maxBytesToUse,
|
MidiMessage (const void* data, int maxBytesToUse,
|
||||||
int& numBytesUsed, uint8 lastStatusByte,
|
int& numBytesUsed, uint8 lastStatusByte,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue