From: simon Date: Tue, 26 Apr 2011 13:44:27 +0000 (+0000) Subject: Fix two memory leaks reported by Tiago Dionizio in recent Loopy X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/commitdiff_plain/a6bd4b9c9f5c5918bf56b50c5d31a4c31104c2ec Fix two memory leaks reported by Tiago Dionizio in recent Loopy development. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@9163 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/grid.c b/grid.c index d73e521..d7e6442 100644 --- a/grid.c +++ b/grid.c @@ -454,6 +454,14 @@ static void grid_trim_vigorously(grid *g) dots[i] = (dots[i] ? newdots++ : -1); /* + * Free the dynamically allocated 'dots' pointer lists in faces + * we're going to discard. + */ + for (i = 0; i < g->num_faces; i++) + if (faces[i] < 0) + sfree(g->faces[i].dots); + + /* * Go through and compact the arrays. */ for (i = 0; i < g->num_dots; i++) diff --git a/loopy.c b/loopy.c index 6e97acd..43e96a7 100644 --- a/loopy.c +++ b/loopy.c @@ -917,6 +917,8 @@ static game_drawstate *game_new_drawstate(drawing *dr, game_state *state) static void game_free_drawstate(drawing *dr, game_drawstate *ds) { + sfree(ds->textx); + sfree(ds->texty); sfree(ds->clue_error); sfree(ds->clue_satisfied); sfree(ds->lines);