It looks like this was mostly fixed in CVS, but the data types chosen
still aren't quite correct.  Rule of thumb:  The type in sizeof() should
have one fewer * than the type of the variable to which the result of
malloc is being assigned.  Here's a patch:

Use the correct types in sizeof when allocating a 3d array.   The change
of float* to float** probably won't have any effect, but float and
float* may be different sizes.

Index: gnubg/board3d/misc3d.c
===================================================================
--- gnubg.orig/board3d/misc3d.c 2006-05-20 16:17:02.000000000 -0700
+++ gnubg/board3d/misc3d.c      2006-05-20 16:17:27.000000000 -0700
@@ -790,12 +790,12 @@ void initDT(diceTest* dt, int x, int y, 
 float ***Alloc3d(int x, int y, int z)
 {      /* Allocate 3d array */
        int i, j;
-       float ***array = (float ***)malloc(sizeof(float*) * x);
+       float ***array = (float ***)malloc(sizeof(float**) * x);
        for (i = 0; i < x; i++)
        {
                array[i] = (float **)malloc(sizeof(float*) * y);
                for (j = 0; j < y; j++)
-                       array[i][j] = (float *)malloc(sizeof(float*) * z);
+                       array[i][j] = (float *)malloc(sizeof(float) * z);
        }
        return array;
 }


-- 
Russ Allbery ([EMAIL PROTECTED])             <http://www.eyrie.org/~eagle/>


_______________________________________________
Bug-gnubg mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gnubg

Reply via email to