From 42706644f944aae5213d9f605010537748aecf6b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 30 Oct 2021 14:16:43 +0200 Subject: [PATCH] fixed out-of-bounds bug when score was not added to high score list If the score is not added to the local high score list for a solved level (because the high score table is completely full, and the new score is not better than the lowest score entry in the list), there was an out-of-bounds bug caused (by accessing the score array at position "-1", which was not correctly handled as "no score entry"). This uncaught error condition could have caused various misbehavior (inclusing crashes) of the game. This change fixes this bug. --- src/game.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game.c b/src/game.c index abc56d23..4d1d9a85 100644 --- a/src/game.c +++ b/src/game.c @@ -5140,12 +5140,12 @@ void NewHighScore(int level_nr, boolean tape_saved) // store last added local score entry (before merging server scores) scores.last_added_local = scores.last_added; - } - if (game.LevelSolved_SaveTape) - { - SaveScoreTape(level_nr); - SaveServerScore(level_nr, tape_saved); + if (game.LevelSolved_SaveTape) + { + SaveScoreTape(level_nr); + SaveServerScore(level_nr, tape_saved); + } } } -- 2.34.1