MapReader: Reject maps with out-of-range terrain tile texture index

m_Tex1Index is unvalidated (raw .pmp bytes / RMS script) and was used
to index m_TerrainTextures with no bounds check.
This commit is contained in:
Fabio Pedretti
2026-08-26 11:48:27 +02:00
committed by Ralph Sennhauser
parent d37db2ba07
commit e4e50d7711
+3
View File
@@ -358,6 +358,9 @@ int CMapReader::ApplyTerrainData()
for (ssize_t k=0; k<PATCH_SIZE; k++) {
CMiniPatch& mp = pTerrain->GetPatch(i,j)->m_MiniPatches[m][k]; // can't fail
if (tileptr->m_Tex1Index >= m_TerrainTextures.size())
throw PSERROR_Game_World_MapLoadFailed("Error loading map: terrain tile references an invalid texture index.\nCheck application log for details.");
mp.Tex = m_TerrainTextures[tileptr->m_Tex1Index];
mp.Priority = tileptr->m_Priority;