[AD] segfaulting on bad midis + workaround

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


Hi,

I found the reason for my problems with the Allegro demo. The data-file
was corrupted, but in a special way. I still could open it with grabber
and play the midi files included there, but the game crashed while
loading patches for this midi data. It costed me some time to find the
reason, so I changed midi.c a bit: Now the users get a message when
something similar happens.

Eduard.
-- 
=====================================================================
Eduard Bloch <eb@xxxxxxxxxx>; HP: http://eduard.bloch.com/edecosi
0xEDF008C5(GnuPG): E6EB 98E2 B885 8FF0 6C04  5C1D E106 481E EDF0 08C5
:wq
--- midi.c.orig	Wed Jun 14 14:26:15 2000
+++ midi.c	Wed Jun 14 13:49:54 2000
@@ -1054,7 +1054,14 @@
       running_status = 0;
 
       while (p < end) {                         /* work through data stream */
-	 event = *p; 
+	 if (p != NULL)
+       event = *p; 
+    else {                                      /* a bad thing, unusable
+                                                   midi data*/
+       allegro_message("MIDI source is corrupted, exiting...\n");
+       allegro_exit();
+    };
+    
 	 if (event & 0x80) {                    /* regular message */
 	    p++;
 	    if ((event != 0xF0) && (event != 0xF7) && (event != 0xFF))


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