aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--code/client/snd_codec_ogg.c5
-rw-r--r--code/client/snd_openal.c16
2 files changed, 19 insertions, 2 deletions
diff --git a/code/client/snd_codec_ogg.c b/code/client/snd_codec_ogg.c
index 464d8d3..9c17c0b 100644
--- a/code/client/snd_codec_ogg.c
+++ b/code/client/snd_codec_ogg.c
@@ -412,7 +412,7 @@ where we read the whole stream at once.
void *S_OGG_CodecLoad(const char *filename, snd_info_t *info)
{
snd_stream_t *stream;
- unsigned char *buffer;
+ byte *buffer;
int bytesRead;
// check if input is valid
@@ -452,8 +452,9 @@ void *S_OGG_CodecLoad(const char *filename, snd_info_t *info)
// we don't even have read a single byte
if(bytesRead <= 0)
{
+ Z_Free(buffer);
S_OGG_CodecCloseStream(stream);
-
+
return NULL;
}
diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c
index 4fbb2ec..01b7fa2 100644
--- a/code/client/snd_openal.c
+++ b/code/client/snd_openal.c
@@ -1377,7 +1377,23 @@ void S_AL_StartBackgroundTrack( const char *intro, const char *loop )
// Queue the musicBuffers up
for(i = 0; i < NUM_MUSIC_BUFFERS; i++)
+ {
S_AL_MusicProcess(musicBuffers[i]);
+
+ // check whether our stream still exists.
+ if(!mus_stream)
+ {
+ // there was an error in reading which resulted in a
+ // closed stream. We must bail out or we'll crash.
+
+ // deallocate everything we allocated so far:
+ qalDeleteBuffers(NUM_MUSIC_BUFFERS, musicBuffers);
+ S_AL_MusicSourceFree();
+
+ return;
+ }
+ }
+
qalSourceQueueBuffers(musicSource, NUM_MUSIC_BUFFERS, musicBuffers);
// Set the initial gain property