fixed accessing array out of bounds
authorHolger Schemel <info@artsoft.org>
Thu, 20 Oct 2022 16:40:57 +0000 (18:40 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 20 Oct 2022 16:40:57 +0000 (18:40 +0200)
This issue was found by using Clang with option "-fsanitize=undefined".

src/game.c

index 97617bb336003beddee02f2b2f1d37b73ea81d49..3a2c1a11db4b5bf290f038fe0124b6d59faaf6a2 100644 (file)
@@ -1784,7 +1784,7 @@ static void InitPlayerField(int x, int y, int element, boolean init_game)
       player->active = TRUE;
 
       // remove potentially duplicate players
-      if (StorePlayer[jx][jy] == Tile[x][y])
+      if (IN_LEV_FIELD(jx, jy) && StorePlayer[jx][jy] == Tile[x][y])
        StorePlayer[jx][jy] = 0;
 
       StorePlayer[x][y] = Tile[x][y];