summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2014-04-10 00:20:06 -0400
committerSimon Howard2014-04-10 00:20:06 -0400
commit174fe185ec8b05a1dc6ce8c49ffc5a0aa1c81855 (patch)
treebde77583d51fc504aea88be7a6c5491781da40ee /src
parent46fb2a7c8c804bb1e131d32e900e408e2e751dbf (diff)
downloadchocolate-doom-174fe185ec8b05a1dc6ce8c49ffc5a0aa1c81855.tar.gz
chocolate-doom-174fe185ec8b05a1dc6ce8c49ffc5a0aa1c81855.tar.bz2
chocolate-doom-174fe185ec8b05a1dc6ce8c49ffc5a0aa1c81855.zip
sound: Fix crash with large values of snd_channels.
Sanity check the handles passed to the i_sdlsound.c API functions and ignore requests that involve channel numbers higher than 15. This fixes a crash if the user sets the snd_channels config variable is set to a high value. This fixes #149 (thanks Alexandre Xavier).
Diffstat (limited to 'src')
-rw-r--r--src/i_sdlsound.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index 2a1d83bc..5cacbc1e 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -826,7 +826,7 @@ static void I_SDL_UpdateSoundParams(int handle, int vol, int sep)
{
int left, right;
- if (!sound_initialized)
+ if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
{
return;
}
@@ -869,7 +869,7 @@ static int I_SDL_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep)
{
allocated_sound_t *snd;
- if (!sound_initialized)
+ if (!sound_initialized || channel < 0 || channel >= NUM_CHANNELS)
{
return -1;
}
@@ -901,9 +901,9 @@ static int I_SDL_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep)
return channel;
}
-static void I_SDL_StopSound (int handle)
+static void I_SDL_StopSound(int handle)
{
- if (!sound_initialized)
+ if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
{
return;
}
@@ -919,7 +919,7 @@ static void I_SDL_StopSound (int handle)
static boolean I_SDL_SoundIsPlaying(int handle)
{
- if (handle < 0)
+ if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
{
return false;
}