[AD] tiny seekmidi fix

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


There's a small bug in seekmidi, for some .mid files midi_pos will wrap
around to the negative length inside the loop when passing an argument
bigger than the length, causing an endless loop. My patch fixes it.

The bug can be seen by replacing play_midi() in exmidi.c with:

play_midi ();
seek_midi (INT_MAX); // this will never return
length = - midi_pos;
play_midi ();

--
Elias Pschernig

Index: src/midi.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/midi.c,v
retrieving revision 1.14
diff -u -r1.14 midi.c
--- src/midi.c	21 Mar 2002 09:33:45 -0000	1.14
+++ src/midi.c	12 Aug 2002 09:38:54 -0000
@@ -1341,7 +1341,7 @@
       prepare_to_play(midifile);
 
    /* now sit back and let midi_player get to the position */
-   while ((midi_pos < target) && (midi_pos != -1)) {
+   while ((midi_pos < target) && (midi_pos >= 0)) {
       int mmpc = midi_pos_counter;
       int mmp = midi_pos;
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/