summaryrefslogtreecommitdiff
path: root/src/i_sound.c
diff options
context:
space:
mode:
authorSimon Howard2008-10-05 18:29:37 +0000
committerSimon Howard2008-10-05 18:29:37 +0000
commitdc7d72797f1d6810b8ba2f8472f6828f1f714df6 (patch)
treefda180504322832d74078749f54ae2093a552a51 /src/i_sound.c
parentda447edca541fa48dde32a69752e74549b7373a4 (diff)
downloadchocolate-doom-dc7d72797f1d6810b8ba2f8472f6828f1f714df6.tar.gz
chocolate-doom-dc7d72797f1d6810b8ba2f8472f6828f1f714df6.tar.bz2
chocolate-doom-dc7d72797f1d6810b8ba2f8472f6828f1f714df6.zip
Perform bounds checking on separation and volume values passed to the
low-level sound code, as the Heretic s_sound.c code generates values that are out of range. Subversion-branch: /branches/raven-branch Subversion-revision: 1337
Diffstat (limited to 'src/i_sound.c')
-rw-r--r--src/i_sound.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/i_sound.c b/src/i_sound.c
index 2a29ccff..439f8689 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -249,10 +249,32 @@ void I_UpdateSound(void)
}
}
+static void CheckVolumeSeparation(int *sep, int *vol)
+{
+ if (*sep < 0)
+ {
+ *sep = 0;
+ }
+ else if (*sep > 254)
+ {
+ *sep = 254;
+ }
+
+ if (*vol < 0)
+ {
+ *vol = 0;
+ }
+ else if (*vol > 127)
+ {
+ *vol = 127;
+ }
+}
+
void I_UpdateSoundParams(int channel, int vol, int sep)
{
if (sound_module != NULL)
{
+ CheckVolumeSeparation(&vol, &sep);
sound_module->UpdateSoundParams(channel, vol, sep);
}
}
@@ -261,6 +283,7 @@ int I_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep)
{
if (sound_module != NULL)
{
+ CheckVolumeSeparation(&vol, &sep);
return sound_module->StartSound(sfxinfo, channel, vol, sep);
}
else