From ead2ab6a6b974672dcfe0991ccdbaacf9d7112d0 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 22 Apr 2021 11:44:53 +0200 Subject: [PATCH] EFX/env_sound: Add bound checks for legacy roomtypes. --- src/client/efx.qc | 8 ++++++-- src/gs-entbase/client/env_sound.qc | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/efx.qc b/src/client/efx.qc index 0ddc7e05..c37e1fb7 100644 --- a/src/client/efx.qc +++ b/src/client/efx.qc @@ -156,9 +156,13 @@ EFX_Load(string efx_file) void EFX_SetEnvironment(int id) { - if (g_iEFX == id) { + /* out of bounds... MAP BUG! */ + if (id >= g_efx_count) + return; + + /* same as before, skip */ + if (g_iEFX == id) return; - } g_iEFXold = g_iEFX; g_iEFX = id; diff --git a/src/gs-entbase/client/env_sound.qc b/src/gs-entbase/client/env_sound.qc index de14f375..450a560b 100644 --- a/src/gs-entbase/client/env_sound.qc +++ b/src/gs-entbase/client/env_sound.qc @@ -94,7 +94,12 @@ env_sound::SpawnKey(string strField, string strKey) /* GoldSrc, legacy */ case "roomtype": int efx_alias = stoi(strKey); - m_iRoomType = EFX_Load(g_hlefx[efx_alias]); + + if (efx_alias >= g_hlefx.length) { + print("^1env_sound::SpawnKey: Invalid roomtype!\n"); + m_iRoomType = 0; + } else + m_iRoomType = EFX_Load(g_hlefx[efx_alias]); break; default: CBaseEntity::SpawnKey(strField, strKey);