summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-08 17:03:33 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-08 17:10:29 +0100
commite3b507957242134019dd12b4be73350f0ead6475 (patch)
tree3275d3627df87b4c8b81c9c83f9032924fc63092
parent921cea1f77addd23e545ac309d32f2d0cabf551b (diff)
fix invalid write in new_enemy_team and in Fjouer
in the function `new_enemy_team()', we used to loop through the enemies while the incrementer is less or equal to the count. However, since there are `count' elements, we need to stop the loop when the incrementer gets equal to `count' the same bug is present in `Fjouer()' when checking if the player wins. Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
-rw-r--r--jouer.c2
-rw-r--r--menuchoixpersos.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/jouer.c b/jouer.c
index 7175191..8603df7 100644
--- a/jouer.c
+++ b/jouer.c
@@ -309,7 +309,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *ally, struc
// on vérifie à présent si on a gagné ou si on a perdu !
gagne=1;
perdu=1;
- for(i = 0; i <= enemy->chr_cnt; i++) {
+ for (i = 0; i < enemy->chr_cnt; i++) {
if (enemy->chrs[i].alive)
gagne=0;
}
diff --git a/menuchoixpersos.c b/menuchoixpersos.c
index 3a40875..f3f5cd3 100644
--- a/menuchoixpersos.c
+++ b/menuchoixpersos.c
@@ -109,7 +109,7 @@ static void generate_enemy_types(const struct team_t *ally_team,
if (avg < 5)
{
/* easy */
- for (int i = 0; i <= count; i++) {
+ for (int i = 0; i < count; i++) {
classes[i] = CLASS_WARRIOR_GOBELIN;
}
} else {