Skip to content

Commit

Permalink
Fixed bug 1299 - Fixed timidity parsing of certain MIDI files with ex…
Browse files Browse the repository at this point in the history
…tra data at the end of the tracks

If the track ends before the size of the track data, skip any junk at the end.
  • Loading branch information
slouken committed Jan 1, 2012
1 parent bbac4ea commit aa932c8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions timidity/readmidi.c
Expand Up @@ -530,7 +530,7 @@ static int read_track(int append)
{
MidiEventList *meep;
MidiEventList *next, *new;
int32 len;
int32 len, next_pos, pos;
char tmp[4];

meep=evlist;
Expand All @@ -552,7 +552,7 @@ static int read_track(int append)
return -1;
}
len=BE_LONG(len);

next_pos = SDL_RWtell(rw) + len;
if (memcmp(tmp, "MTrk", 4))
{
ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
Expand All @@ -567,6 +567,9 @@ static int read_track(int append)

if (new==MAGIC_EOT) /* End-of-track Hack. */
{
pos = SDL_RWtell(rw);
if (pos < next_pos)
SDL_RWseek(rw, next_pos - pos, RW_SEEK_CUR);
return 0;
}

Expand Down

0 comments on commit aa932c8

Please sign in to comment.