From a5a17e45cf5377c794dc0ad65581cc1d69ee8aca Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Dec 2014 20:43:40 +0100 Subject: [PATCH] - fixed: Checking the terrain for any texture that was created after initializing the terrain data either returned random garbage or could even create an access violation. Added a range check to the array access function to prevent this. --- src/p_terrain.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_terrain.h b/src/p_terrain.h index d2933b687a..9f00d07bcd 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -49,11 +49,13 @@ public: WORD operator [](FTextureID tex) const { + if ((unsigned)tex.GetIndex() >= Types.Size()) return DefaultTerrainType; WORD type = Types[tex.GetIndex()]; return type == 0xffff? DefaultTerrainType : type; } WORD operator [](int texnum) const { + if ((unsigned)texnum >= Types.Size()) return DefaultTerrainType; WORD type = Types[texnum]; return type == 0xffff? DefaultTerrainType : type; }