chiark / gitweb /
Fix tiny memory leak if you pressed Solve while part way through an
authorSimon Tatham <anakin@pobox.com>
Sat, 12 May 2007 08:26:58 +0000 (08:26 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 12 May 2007 08:26:58 +0000 (08:26 +0000)
existing solution path.

[originally from svn r7571]

inertia.c

index 4e84f56f3a1f7ed4664995c2d191db7974fe07c5..dd80ebef1c04961fa25746941332fe22632255a5 100644 (file)
--- a/inertia.c
+++ b/inertia.c
@@ -1626,6 +1626,10 @@ static game_state *execute_move(game_state *state, char *move)
            sol->list[i] = move[i] - '0';
        ret = dup_game(state);
        ret->cheated = TRUE;
+       if (ret->soln && --ret->soln->refcount == 0) {
+           sfree(ret->soln->list);
+           sfree(ret->soln);
+       }
        ret->soln = sol;
        ret->solnpos = 0;
        sol->refcount = 1;