X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/096122ce3658e79e342d5c5ef0cee44521c7ea31..74021716bcfa8fa7ae59c584e3038b7d7a3e5441:/inertia.c diff --git a/inertia.c b/inertia.c index a158363..95bdcc8 100644 --- a/inertia.c +++ b/inertia.c @@ -221,6 +221,9 @@ static struct solver_scratch *new_scratch(int w, int h) static void free_scratch(struct solver_scratch *sc) { + sfree(sc->reachable_from); + sfree(sc->reachable_to); + sfree(sc->positions); sfree(sc); } @@ -370,7 +373,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); @@ -938,6 +943,8 @@ static game_drawstate *game_new_drawstate(drawing *dr, game_state *state) static void game_free_drawstate(drawing *dr, game_drawstate *ds) { + if (ds->player_background) + blitter_free(dr, ds->player_background); sfree(ds->grid); sfree(ds); }