From dc7d72797f1d6810b8ba2f8472f6828f1f714df6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 5 Oct 2008 18:29:37 +0000 Subject: 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 --- src/i_sound.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/i_sound.c') 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 -- cgit v1.2.3