summaryrefslogtreecommitdiff
blob: 5e45721b1aa83d0128079c9bcd6a833403352e0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
For bug 397333
https://bugs.gentoo.org/show_bug.cgi?id=397333

upstream patch pulled from:
http://hg.libsdl.org/SDL_mixer/raw-diff/7a8f0018e23d/timidity/readmidi.c

--- a/timidity/readmidi.c
+++ b/timidity/readmidi.c
@@ -530,7 +530,7 @@
 {
   MidiEventList *meep;
   MidiEventList *next, *new;
-  int32 len;
+  int32 len, next_pos, pos;
   char tmp[4];
 
   meep=evlist;
@@ -552,7 +552,7 @@
       return -1;
     }
   len=BE_LONG(len);
-
+  next_pos = SDL_RWtell(rw) + len;
   if (memcmp(tmp, "MTrk", 4))
     {
       ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
@@ -567,6 +567,9 @@
 
       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;
 	}