ref: 174fe185ec8b05a1dc6ce8c49ffc5a0aa1c81855
parent: 46fb2a7c8c804bb1e131d32e900e408e2e751dbf
author: Simon Howard <[email protected]>
date: Wed Apr 9 20:20:06 EDT 2014
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).
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -826,7 +826,7 @@
{
int left, right;
- if (!sound_initialized)
+ if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
{
return;
}
@@ -869,7 +869,7 @@
{
allocated_sound_t *snd;
- if (!sound_initialized)
+ if (!sound_initialized || channel < 0 || channel >= NUM_CHANNELS)
{
return -1;
}
@@ -901,9 +901,9 @@
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 boolean I_SDL_SoundIsPlaying(int handle)
{
- if (handle < 0)
+ if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
{
return false;
}