[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnugo-devel] More bad DRAGON2 accesses
From: |
Trevor Morris |
Subject: |
[gnugo-devel] More bad DRAGON2 accesses |
Date: |
Sun, 24 Feb 2002 11:37:58 -0500 |
Here's a version of DRAGON2 that catches more problems. This
time it shows up in owl helpers using the DRAGON_WEAK macro.
Again, I'll just be the bearer of bad news, and punt on a fix.
http://www.public32.com/games/go/crash_1_26.2
- Version of DRAGON2 macro that bounds-verifies.
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.81
diff -u -r1.81 liberty.h
--- engine/liberty.h 16 Feb 2002 15:58:03 -0000 1.81
+++ engine/liberty.h 24 Feb 2002 16:27:55 -0000
@@ -720,9 +720,17 @@
/* Macros for accessing the dragon2 data with board coordinates and
* the dragon data with a dragon id.
- */
-#define DRAGON2(pos) dragon2[dragon[pos].id]
+ */
+#if 0 /* Trust DRAGON2 accesses? */
+#define DRAGON2(pos) dragon2[dragon[pos].id]
+#else
+struct dragon_data2 * dragon2_func(int pos);
+#define DRAGON2(pos) (*dragon2_func(pos))
+#endif
+
#define DRAGON(d) dragon[dragon2[d].origin]
+
+
struct aftermath_data {
int white_captured;
Index: patterns/helpers.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/helpers.c,v
retrieving revision 1.28
diff -u -r1.28 helpers.c
--- patterns/helpers.c 13 Feb 2002 05:40:10 -0000 1.28
+++ patterns/helpers.c 24 Feb 2002 16:28:07 -0000
@@ -665,6 +665,18 @@
return result;
}
+
+
+/* Alternative for DRAGON2 macro with asserts. */
+struct dragon_data2 *
+dragon2_func(int pos)
+{
+ ASSERT1(ON_BOARD1(pos)
+ && dragon[pos].id >= 0
+ && dragon[pos].id < number_of_dragons, pos);
+ return &dragon2[dragon[pos].id];
+}
+
/*
- [gnugo-devel] More bad DRAGON2 accesses,
Trevor Morris <=