git repos / blockattack-game

commit 83b95511

Poul Sander · 2025-05-30 19:54
83b95511a30f5db0f2f6bfde5f04a1fda69ed70e patch · browse files
parent 1ae9f2021fe6782337e890c53381fa1156abedff

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];
}