Mikmod EOF problems.

Tom Rothamel tom at rothamel.us
Wed Dec 21 12:35:52 EST 2005

I've discovered a problem with the code that SDL_sound uses to integrate 
with mikmod. Playing certain .xm files causes playsound to segfault. I 
tracked the root cause of the problem down to SDL_sound's definition of 
an eof condition (in mikmod.c) being different than what the C library 
and mikmod expect.

In those libraries, eof is signaled only when attempting to read after 
the end of the file. In SDL_sound, however, eof is signaled by the 
location of the file being at the end of the file, even if it never 
attempted to read past the end of the file.

The XM file in question stores a sample at the end of the file, and then 
seems to seek back to find something else, reading the last byte of the 
file but never reading past.

The attached patch changes the eof behavior of mikmod.c to match that 
which mikmod expects.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: eof.diff
Type: text/x-patch
Size: 2092 bytes
Desc: not available
URL: <http://icculus.org/pipermail/sdlsound/attachments/20051221/9175e064/attachment.bin>

More information about the sdlsound mailing list