gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] valgrind_3_7.1: fix in sniff_lunch()


From: Arend Bayer
Subject: [gnugo-devel] valgrind_3_7.1: fix in sniff_lunch()
Date: Thu, 29 Aug 2002 12:49:23 +0200 (CEST)

The tool valgrind (http://developer.kde.org/~sewardj/) is, if I understand
correctly, perfect in detecting use of uninitialized memory (it may also
have a good chance at capturing out-of-bound memory access).

I tried it out with gnugo (it is very easy to use: "valgrind gnugo"), and
it immediately had two complaints, one of them relevant. (I've fixed the
other one too.) With the patch applied, there were no further problems so
far (it's pretty slow, so I've only run half the lazarus test suite).

No changed regression.

Arend

- bugfix (reading uninitialized memory) in sniff_lunch()

Index: engine/dragon.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v
retrieving revision 1.69
diff -u -r1.69 dragon.c
--- engine/dragon.c     8 Aug 2002 23:03:03 -0000       1.69
+++ engine/dragon.c     29 Aug 2002 10:43:42 -0000
@@ -1620,8 +1620,8 @@
     float this_moyo_value = 0.0;
     for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
       int moyo_number = moyos.segmentation[pos];
-      if (moyo_number == 0
-          || board[pos] != DRAGON(d).color
+      if (board[pos] != DRAGON(d).color
+          || moyo_number == 0
           || dragon[pos].id != d
           || moyos.owner[moyo_number] != board[pos])
         continue;
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.99
diff -u -r1.99 owl.c
--- engine/owl.c        11 Aug 2002 12:13:02 -0000      1.99
+++ engine/owl.c        29 Aug 2002 10:44:03 -0000
@@ -4424,7 +4424,7 @@
        && !is_self_atari(libs[r], other)) {
       int k;
       for (k = 0; k < 8; k++)
-       if (owl->goal[libs[r] + delta[k]])
+       if (ON_BOARD(libs[r] + delta[k]) && owl->goal[libs[r] + delta[k]])
          break;
       if (k == 8) {
        *min = 2;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]