From: Guus Sliepen Date: Mon, 10 Aug 2015 13:39:01 +0000 (+0200) Subject: Fix reading one element past the end of an array. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=483925fc4f07ba70a562bb3297011885c82ed64b;p=quix0rs-blobwars.git Fix reading one element past the end of an array. Found by cppcheck. --- 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;