]> git.cworth.org Git - loa/commitdiff
Fix check for out-of-range values passed to loa_board_move_legal
authorCarl Worth <cworth@cworth.org>
Fri, 29 Feb 2008 05:23:50 +0000 (21:23 -0800)
committerCarl Worth <cworth@cworth.org>
Fri, 29 Feb 2008 05:23:50 +0000 (21:23 -0800)
Previously we were only checking the first coordinate pair
instead of both. Oops.

loa-board.c

index 5eb9cc5ab4984b87a8b050e06a8b20c2ada3b0c3..8ea6f99d36bb45ad758011bee975ef57faf3c86a 100644 (file)
@@ -186,7 +186,9 @@ loa_board_move_legal (loa_board_t *board,
     int dx, dy;
     int step_x, step_y;
 
-    if (x1 < 0 || y1 < 0 || x1 >= LOA_BOARD_SIZE || y1 >= LOA_BOARD_SIZE) {
+    if (x1 < 0 || y1 < 0 || x1 >= LOA_BOARD_SIZE || y1 >= LOA_BOARD_SIZE ||
+       x2 < 0 || y2 < 0 || x2 >= LOA_BOARD_SIZE || y2 >= LOA_BOARD_SIZE)
+    {
        *error = "Invalid coordinates (not on board)";
        return FALSE;
     }