shithub: puzzles

Download patch

ref: 4bab5e531b4b49c9b41d2140dd570d05947e7c40
parent: 8266b71475d2366a530b34d46a43dce3eceed2ff
author: Simon Tatham <anakin@pobox.com>
date: Tue Apr 26 09:44:27 EDT 2011

Fix two memory leaks reported by Tiago Dionizio in recent Loopy
development.

[originally from svn r9163]

--- a/grid.c
+++ b/grid.c
@@ -454,6 +454,14 @@
         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++)
--- a/loopy.c
+++ b/loopy.c
@@ -917,6 +917,8 @@
 
 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);