]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Fix reading one element past the end of an array.
authorGuus Sliepen <guus@debian.org>
Mon, 10 Aug 2015 13:39:01 +0000 (15:39 +0200)
committerGuus Sliepen <guus@debian.org>
Mon, 10 Aug 2015 13:39:01 +0000 (15:39 +0200)
Found by cppcheck.

src/enemies.cpp

index 41d31e612ddbf0883c6d62622d0045a39d726af8..679d6d996213217993ebd3758e6aa2633e3414bb 100644 (file)
@@ -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;