SDL_mixer seg fault

I’ve written a short program that causes SDL_mixer to seg fault. It
loads a S3M, starts to play it, and loads another one. Then it seg
faults.

I tried using different S3Ms, but this didn’t happen. I’m not sure if
the seg fault has to do with SDL_mixer or MikMod, or maybe I just didn’t
understand how I’m supposed to use the whole mixer thing. My guess is
there is something wrong with those two S3Ms that make the whole thing
crash.

The problem seems to be fixed if I stop playing of the first S3M before
I load the second. However in the larger program I’m working on it
would be nice if I could have both of these modules in memory at the
same time.

The S3Ms are from the “Freedom CD” in the music/disks/a_f/fdragon*.zip,
or from
http://it.aminet.net/pub/demo/ftp.hornet.org/music/disks/1995/fdragon.zip

Here is the shortest code segment I could create to get this seg fault
to happen:
[testmix.cc]

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include “SDL.h”
#include “SDL_mixer.h”

main()
{
SDL_Init(SDL_INIT_AUDIO);

int audio_rate=44100;
Uint16 audio_format=AUDIO_S16;
int audio_channels=2;
int audio_buffers=1024;//4096;

if (Mix_OpenAudio(audio_rate, audio_format, audio_channels,

audio_buffers) < 0) {
fprintf(stderr, “Couldn’t open audio: %s\n”, SDL_GetError());
exit(2);
} else {
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
printf(“Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n”,
audio_rate,
(audio_format&0xFF),
(audio_channels > 1) ? “stereo” : “mono”,
audio_buffers );
}

/* Set the external music player, if any */
Mix_SetMusicCMD(getenv("MUSIC_CMD"));

Mix_Music *m1;
Mix_Music *m2;

m1=Mix_LoadMUS("DREAM.S3M");
Mix_PlayMusic(m1,-1);
m2=Mix_LoadMUS("ENIGMA.S3M");
if (Mix_PlayingMusic()) Mix_HaltMusic();
Mix_PlayMusic(m2,-1);
Mix_FreeMusic(m1);
if (Mix_PlayingMusic()) Mix_HaltMusic();
Mix_FreeMusic(m2);	


printf ("Closing audio.\n");
Mix_HaltMusic();
Mix_HaltChannel(1);
Mix_CloseAudio();

SDL_Quit();
}

Thanks for your help,
-Phil