chiark / gitweb /
James Harvey (again) points out an array underrun in the new
authorSimon Tatham <anakin@pobox.com>
Tue, 7 Jun 2005 19:07:58 +0000 (19:07 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 7 Jun 2005 19:07:58 +0000 (19:07 +0000)
clash-checking code in Solo. (valgrind confirms it.)

[originally from svn r5916]

solo.c

diff --git a/solo.c b/solo.c
index 2f8ec23b51460d06ea8590e0591ea6f976e01f37..d564ad2d25c914c8821e0de7c1c0c5eb60849558 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -2238,9 +2238,9 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
 
            /* Mark obvious errors (ie, numbers which occur more than once
             * in a single row, column, or box). */
-           if ((ds->entered_items[x*cr+d-1] & 2) ||
-               (ds->entered_items[y*cr+d-1] & 8) ||
-               (ds->entered_items[((x/r)+(y/c)*c)*cr+d-1] & 32))
+           if (d && ((ds->entered_items[x*cr+d-1] & 2) ||
+                     (ds->entered_items[y*cr+d-1] & 8) ||
+                     (ds->entered_items[((x/r)+(y/c)*c)*cr+d-1] & 32)))
                highlight |= 16;
 
            draw_number(fe, ds, state, x, y, highlight);