From 483925fc4f07ba70a562bb3297011885c82ed64b Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 10 Aug 2015 15:39:01 +0200 Subject: [PATCH] Fix reading one element past the end of an array. Found by cppcheck. --- src/enemies.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/enemies.cpp b/src/enemies.cpp index 41d31e6..679d6d9 100644 --- a/src/enemies.cpp +++ b/src/enemies.cpp @@ -821,7 +821,7 @@ void loadEnemy(const char *token) { int enemy = -1; - for (int i = MAX_ENEMIES ; i > -1 ; i--) + for (int i = MAX_ENEMIES - 1; i >= 0; i--) if (strcmp(defEnemy[i].name, "") == 0) enemy = i; -- 2.39.5