chiark / gitweb /
Fix segfault in Loopy printing, introduced when I added the dynamic
authorSimon Tatham <anakin@pobox.com>
Wed, 11 May 2011 18:11:28 +0000 (18:11 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 11 May 2011 18:11:28 +0000 (18:11 +0000)
arrays 'textx' and 'texty' to the game_drawstate but failed to
initialise them in the temporary drawstate used by game_print().
Thanks to Arun Giridhar for spotting this.

[originally from svn r9173]

loopy.c

diff --git a/loopy.c b/loopy.c
index e7fb6cb02223a9d8940d72202c8e645e7c88f8bd..b84ca8241d62e0c753fd5b7f3dd2d782c4e57737 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -3805,6 +3805,10 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
     grid *g = state->game_grid;
 
     ds->tilesize = tilesize;
+    ds->textx = snewn(g->num_faces, int);
+    ds->texty = snewn(g->num_faces, int);
+    for (i = 0; i < g->num_faces; i++)
+        ds->textx[i] = ds->texty[i] = -1;
 
     for (i = 0; i < g->num_dots; i++) {
         int x, y;
@@ -3874,6 +3878,9 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
             }
         }
     }
+
+    sfree(ds->textx);
+    sfree(ds->texty);
 }
 
 #ifdef COMBINED