ref: dc7d72797f1d6810b8ba2f8472f6828f1f714df6
parent: da447edca541fa48dde32a69752e74549b7373a4
author: Simon Howard <[email protected]>
date: Sun Oct 5 14:29:37 EDT 2008
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
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -249,10 +249,32 @@
}
}
+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 @@
{
if (sound_module != NULL)
{
+ CheckVolumeSeparation(&vol, &sep);
return sound_module->StartSound(sfxinfo, channel, vol, sep);
}
else