chiark / gitweb /
Fix two memory leaks reported by Tiago Dionizio in recent Loopy
authorSimon Tatham <anakin@pobox.com>
Tue, 26 Apr 2011 13:44:27 +0000 (13:44 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 26 Apr 2011 13:44:27 +0000 (13:44 +0000)
development.

[originally from svn r9163]

grid.c
loopy.c

diff --git a/grid.c b/grid.c
index d73e521d18bcff3316a8e50924e76c69f67d3ffb..d7e6442bbb28a5d4d5ca6edc0d3de83e3351942f 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -453,6 +453,14 @@ static void grid_trim_vigorously(grid *g)
     for (i = newdots = 0; i < g->num_dots; i++)
         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.
      */
diff --git a/loopy.c b/loopy.c
index 6e97acda48a521e69656a3e415c98ea7352d11a2..43e96a7fb7cb746898604db2733ddb02b176fea2 100644 (file)
--- 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);