Fixed bug 2140 - Track is played back with the wrong tempo
authorSam Lantinga <slouken@libsdl.org>
Sun, 03 Nov 2013 13:33:21 -0800
changeset 6678ef083375857
parent 666 c166c70fc52a
child 668 400f1b6074c0
Fixed bug 2140 - Track is played back with the wrong tempo

ny00

It seems like the test against MAXCHAN can safely be relocated after the check if (meep->event.type==ME_TEMPO), with no risk of memory corruption, at least in this function.
timidity/readmidi.c
     1.1 --- a/timidity/readmidi.c	Sun Nov 03 11:31:19 2013 -0800
     1.2 +++ b/timidity/readmidi.c	Sun Nov 03 13:33:21 2013 -0800
     1.3 @@ -673,15 +673,15 @@
     1.4  		meep->event.time, meep->event.channel + 1,
     1.5  		meep->event.type, meep->event.a, meep->event.b);
     1.6  
     1.7 -      if (meep->event.channel >= MAXCHAN)
     1.8 -	skip_this_event=1;
     1.9 -      else if (meep->event.type==ME_TEMPO)
    1.10 +      if (meep->event.type==ME_TEMPO)
    1.11  	{
    1.12  	  tempo=
    1.13  	    meep->event.channel + meep->event.b * 256 + meep->event.a * 65536;
    1.14  	  compute_sample_increment(tempo, divisions);
    1.15  	  skip_this_event=1;
    1.16  	}
    1.17 +      else if (meep->event.channel >= MAXCHAN)
    1.18 +	skip_this_event=1;
    1.19        else if ((quietchannels & (1<<meep->event.channel)))
    1.20  	skip_this_event=1;
    1.21        else switch (meep->event.type)