gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] 2 arraybound violations in 3.1.22.


From: Teun Burgers
Subject: [gnugo-devel] 2 arraybound violations in 3.1.22.
Date: Thu, 24 Jan 2002 10:35:38 +0100

running 3.1.22 with array bound checking revealed
2 array bound violations.

The first one is in compute_aa_values and
is fixed by this patch.

The second one shows up when filllib.tst is
run with --experimental-semeai. The
matcher_status is 7 for the dragon involved
and this leads to an
arraybound violation on the class_mask array.

Teun

- add assertion to check_pattern_light
- fix arraybound violation in compute_aa_values

--- matchpat.c.orig     Thu Jan 24 10:27:03 2002
+++ matchpat.c  Thu Jan 24 10:25:27 2002
@@ -920,6 +920,7 @@
     }
 
    /* class check */
+    ASSERT2(dragon[POS(x,y)].matcher_status < 4, x, y);
     if ((pattern->class
         & class_mask[dragon[POS(x, y)].matcher_status][p[x][y]]) != 0)
       goto match_failed;
--- combination.c.orig  Thu Jan 24 09:47:12 2002
+++ combination.c       Thu Jan 24 09:52:34 2002
@@ -1084,6 +1084,7 @@
   int liberties;
   int libs[MAXLIBS];
   int mx[BOARDMAX];
+  int librd;
   int r, k;
 
   for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
@@ -1105,14 +1106,15 @@
        value++;
       }
       for (k = 0; k < 4; k++) {
-       if (!mx[libs[r] + delta[k]]) {
-         mx[libs[r] + delta[k]] = 1;
-         if (board[libs[r] + delta[k]] == EMPTY
-             && (influence_moyo_color(libs[r] + delta[k]) == other
-                 || (influence_moyo_color_opposite(libs[r] + delta[k])
+       librd = libs[r] + delta[k];
+       if (!ON_BOARD1(librd) || mx[librd])
+         continue;
+       mx[librd] = 1;
+       if (board[librd] == EMPTY
+             && (influence_moyo_color(librd) == other
+                 || (influence_moyo_color_opposite(librd)
                      == other)))
            value++;
-       }
       }
     }



reply via email to

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