- added proper range check to the main sound playing function.

We got a report where this crashed on a bad sound index.
This commit is contained in:
Christoph Oelckers 2022-01-07 00:16:30 +01:00
parent 63fa01205f
commit 64ef03428d
2 changed files with 2 additions and 2 deletions

View file

@ -388,7 +388,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
FVector3 pos, vel;
FRolloffInfo *rolloff;
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds)
if (sound_id <= 0 || volume <= 0 || nosfx || !SoundEnabled() || blockNewSounds || (unsigned)sound_id >= S_sfx.Size())
return NULL;
// prevent crashes.

View file

@ -416,7 +416,7 @@ static int S_AddSound (const char *logicalname, int lumpnum, FScanner *sc)
sfxid = soundEngine->FindSoundNoHash (logicalname);
if (sfxid > 0)
if ((unsigned int)sfxid < S_sfx.Size())
{ // If the sound has already been defined, change the old definition
sfxinfo_t *sfx = &S_sfx[sfxid];