Commit 3cb91369 authored by toyoshim's avatar toyoshim Committed by Commit bot

Web MIDI: MIDI input messages may be lost or cause a crash on OS X

MIDIPacketList can contain multiple MIDIPacket, but MIDIPacket objects
have different sizes depending on packet contents. So we should not
refer to MIDIPackets via array index, but should use MIDIPacketNext
that Core MIDI API provides to obtain the next object.

As a result, previous code may refer invalid memory region if large
MIDI messages are received at the same time.

BUG=456780, 374560

Review URL: https://codereview.chromium.org/965793002

Cr-Commit-Position: refs/heads/master@{#318653}
parent d3126d1f
......@@ -286,16 +286,18 @@ void MidiManagerMac::ReadMidi(MIDIEndpointRef source,
uint32 port_index = source_map_[source];
// Go through each packet and process separately.
const MIDIPacket* packet = &packet_list->packet[0];
for (size_t i = 0; i < packet_list->numPackets; i++) {
// Each packet contains MIDI data for one or more messages (like note-on).
const MIDIPacket &packet = packet_list->packet[i];
double timestamp_seconds = MIDITimeStampToSeconds(packet.timeStamp);
double timestamp_seconds = MIDITimeStampToSeconds(packet->timeStamp);
ReceiveMidiData(
port_index,
packet.data,
packet.length,
packet->data,
packet->length,
timestamp_seconds);
packet = MIDIPacketNext(packet);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment