From: Jérôme Benoit Date: Sat, 6 May 2017 15:29:44 +0000 (+0200) Subject: TP13 exo2: Fix off-by-one in the pawns displaying loop X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2149ef9b62ec2f732031e77ee640082cc88f38bb;p=TD_C.git TP13 exo2: Fix off-by-one in the pawns displaying loop Signed-off-by: Jérôme Benoit --- diff --git a/TP_13/exo2/lib/display.c b/TP_13/exo2/lib/display.c index 72bd0f5..c60268a 100644 --- a/TP_13/exo2/lib/display.c +++ b/TP_13/exo2/lib/display.c @@ -93,7 +93,7 @@ static int remap_x(int x) { void print_coordinates(coordinates_t coordinates_array[], int base_y, int base_x) { unsigned i = 0; - while ((coordinates_array + i)->y != 0 && (coordinates_array + i)->x != 0) { + while ((coordinates_array + i)->y != 0 && (coordinates_array + i)->x != 0 && i < MAX_COORDINATES) { if ((coordinates_array + i)->type == 0) { print_o(base_y + remap_y((coordinates_array + i)->y), base_x + remap_x((coordinates_array + i)->x)); } else {