From ad0b15699cf384911b15fd6802dbcc375b10ff7a Mon Sep 17 00:00:00 2001 From: CanerKaraca23 <37447503+CanerKaraca23@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:16:33 +0000 Subject: [PATCH 1/2] fix: avoid out-of-bounds array access in modelinfomgr Removes a hacky frame count check previously used to avoid a crash when processing SirenLight materials. Replaces it with proper bounds checking for indices returned by GetSirenIndex and GetStrobeIndex before accessing the associated status arrays. --- src/utils/modelinfomgr.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/modelinfomgr.cpp b/src/utils/modelinfomgr.cpp index af43e7f9..b3b04b02 100755 --- a/src/utils/modelinfomgr.cpp +++ b/src/utils/modelinfomgr.cpp @@ -240,12 +240,6 @@ RpMaterial *ModelInfoMgr::SetEditableMaterialsCB(RpMaterial *material, void *dat { auto &data = m_VehData.Get(pCurVeh); - // Sirens crash fix TODO: remove this and fix it - if (iLightIndex == eMaterialType::SirenLight && data.nFrameCount <= 10) - { - return material; - } - bool lightOn = false; data.m_MatAvail[iLightIndex] = true; @@ -263,11 +257,19 @@ RpMaterial *ModelInfoMgr::SetEditableMaterialsCB(RpMaterial *material, void *dat if (iLightIndex == eMaterialType::SirenLight) { - lightOn = data.m_SirenStatus[GetSirenIndex(pCurVeh, material)]; + int idx = GetSirenIndex(pCurVeh, material); + if (idx >= 0 && idx < MAX_LIGHTS) + { + lightOn = data.m_SirenStatus[idx]; + } } else if (iLightIndex == eMaterialType::StrobeLight) { - lightOn = data.m_StrobeStatus[GetStrobeIndex(pCurVeh, material)]; + int idx = GetStrobeIndex(pCurVeh, material); + if (idx >= 0 && idx < MAX_LIGHTS) + { + lightOn = data.m_StrobeStatus[idx]; + } } else if (iLightIndex != eMaterialType::UnknownMaterial) { From c5cb69281cea7ca14d013d4a7de858c061a7f886 Mon Sep 17 00:00:00 2001 From: CanerKaraca23 <37447503+CanerKaraca23@users.noreply.github.com> Date: Sat, 4 Apr 2026 11:27:40 +0000 Subject: [PATCH 2/2] fix: avoid out-of-bounds array access in modelinfomgr Removes a hacky frame count check previously used to avoid a crash when processing SirenLight materials. Replaces it with proper bounds checking for indices returned by GetSirenIndex and GetStrobeIndex before accessing the associated status arrays.