commit 83b95511
Prevent out of bound accessing puzzles
Changed files
| M | source/code/puzzlehandler.cpp before |
diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp
index 0550453..bcbb74d 100644
--- a/source/code/puzzlehandler.cpp
+++ b/source/code/puzzlehandler.cpp
@@ -46,6 +46,9 @@ int PuzzleNumberOfMovesAllowed(int level) {
}
int PuzzleGetBrick(int level, int x, int y) {
+ if (level >= maxNrOfPuzzleStages || x >= 6 || y >= 12 || level < 0 || x < 0 || y < 0) {
+ return -1;
+ }
return puzzleLevels[level][x][y];
}