gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] 3.3.17: arraybound violation in corner_matchpat


From: Arend Bayer
Subject: Re: [gnugo-devel] 3.3.17: arraybound violation in corner_matchpat
Date: Tue, 4 Mar 2003 16:53:33 +0100 (CET)

Teun wrote:

> gnugo 3.3.17 gives an arraybound violation on line 1369 in corner_matchpat
> for filllib test 4. pos becomes -12 in this pass of the j loop, which is
> a problem for the IS_STONE(board[pos]) test.

Thanks for the testing. I really wonder how many inexplicable bugs we'd
have without your arraybounds checking...

Paul, do you agree with the fix below?

Arend

Index: engine/matchpat.c

===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.53
diff -u -p -r1.53 matchpat.c
--- engine/matchpat.c   3 Feb 2003 23:33:05 -0000       1.53
+++ engine/matchpat.c   4 Mar 2003 15:55:06 -0000
@@ -1366,7 +1366,9 @@ corner_matchpat(corner_matchpat_callback
       for (j = 1; j < database->max_width; j++) {
        pos += dx;
        num_stones[pos] = num_stones[pos - dx] + num_stones[pos - dy]
-                       - num_stones[pos - dx - dy] + IS_STONE(board[pos]);
+                       - num_stones[pos - dx - dy];
+       if (ON_BOARD1(pos) && IS_STONE(board[pos]))
+         num_stones[pos]++;
       }
     }






reply via email to

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