aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-08-27 09:53:38 +0000
committerSimon Tatham <anakin@pobox.com>2005-08-27 09:53:38 +0000
commit389397eed6bf162f1e13b9c733bfa2cf88c2ba83 (patch)
tree5b0df7d1d1a7db75cf1206e3fd016115bf226bf2
parent8c547d5320864bca867ab8008e9e2dd4a4a4bc6b (diff)
downloadpuzzles-389397eed6bf162f1e13b9c733bfa2cf88c2ba83.zip
puzzles-389397eed6bf162f1e13b9c733bfa2cf88c2ba83.tar.gz
puzzles-389397eed6bf162f1e13b9c733bfa2cf88c2ba83.tar.bz2
puzzles-389397eed6bf162f1e13b9c733bfa2cf88c2ba83.tar.xz
Fix array bounds violation in the solver. Oops.
[originally from svn r6225]
-rw-r--r--inertia.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/inertia.c b/inertia.c
index a158363..fc213da 100644
--- a/inertia.c
+++ b/inertia.c
@@ -370,7 +370,9 @@ static int find_gem_candidates(int w, int h, char *grid,
d2 = n;
}
i2 = (y2*w+x2)*DIRECTIONS+d2;
- if (!reachable[i2]) {
+ if (x2 >= 0 && x2 < w &&
+ y2 >= 0 && y2 < h &&
+ !reachable[i2]) {
int ok;
#ifdef SOLVER_DIAGNOSTICS
printf(" trying point %d,%d,%d", x2, y2, d2);