aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sixteen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sixteen.c b/sixteen.c
index b44e925..aa10f4a 100644
--- a/sixteen.c
+++ b/sixteen.c
@@ -762,11 +762,11 @@ static game_state *execute_move(const game_state *from, const char *move)
}
if (move[0] == 'R' && sscanf(move+1, "%d,%d", &cy, &dx) == 2 &&
- cy >= 0 && cy < from->h) {
+ cy >= 0 && cy < from->h && -from->h <= dx && dx <= from->w ) {
cx = dy = 0;
n = from->w;
} else if (move[0] == 'C' && sscanf(move+1, "%d,%d", &cx, &dy) == 2 &&
- cx >= 0 && cx < from->w) {
+ cx >= 0 && cx < from->w && -from->h <= dy && dy <= from->h) {
cy = dx = 0;
n = from->h;
} else