Re: [AD] segfaulting on bad midis + workaround |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
#include <hallo.h>
George Foot wrote on Thu Jun 15, 2000 um 02:22:32PM:
> But your exit isn't very clean. :) Calling `allegro_exit' is
> not really sensible inside an Allegro routine, so I'm assuming
Of course, it's a dirty way to solve the problem.
> you actually meant to exit the program completely (but maybe
> this isn't what you meant). Given your patch, I'd expect the
Exactly what I want.
> program to crash fairly soon after that point, if you just
That's possible, I removed the corrupted file and couldn't find one to
test this.
> detecting this error, if it only occurs because of a corrupted
> datafile. Secondly, even if we should detect this error and do
> something safe, I think the most we should do is return an error
> to the program (and not play the MIDI) and let it handle the
Okay, then even this way, patch attached.
> The demo game doesn't really care whether its music can play.
> If it did, it could check what we put in `allegro_error', and
BTW, some routines seem to be pretty slow in DGA, even slower than in
X-Window-graphics, eg. the fade routines.
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 Sun Jun 18 16:57:31 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*/
+ ustrcpy(allegro_error, get_config_text("MIDI data is corrupted."));
+ return -1;
+ };
+
if (event & 0x80) { /* regular message */
p++;
if ((event != 0xF0) && (event != 0xF7) && (event != 0xFF))