Skip to content

Commit

Permalink
Fix #171071: crash when importing incorrect MIDI file
Browse files Browse the repository at this point in the history
  • Loading branch information
trig-ger authored and lasconic committed Feb 13, 2017
1 parent 1d72a05 commit 548344b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions midi/midifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ bool MidiFile::read(QIODevice* in)
if (memcmp(tmp, "MThd", 4) || len < 6)
throw(QString("bad midifile: MThd expected"));

if (len > 6)
throw(QString("unsupported MIDI header data size: %1 instead of 6").arg(len));

_format = readShort();
int ntracks = readShort();

Expand Down Expand Up @@ -254,9 +257,6 @@ bool MidiFile::read(QIODevice* in)

// =====================================================

if (len > 6)
skip(len-6); // skip the excess

switch (_format) {
case 0:
if (readTrack())
Expand Down

0 comments on commit 548344b

Please sign in to comment.