OSDN Git Service

Fixed bug: uninitialized variable has been used in maketree2().
authorKoji Arai <jca02266@gmail.com>
Tue, 9 Sep 2008 15:46:10 +0000 (00:46 +0900)
committerKoji Arai <jca02266@gmail.com>
Tue, 9 Sep 2008 15:53:11 +0000 (00:53 +0900)
Make sure whether the maketree2() need to use the tree1 info.
This is experimental changes.

src/pm2tree.c

index 5d98bc4..8ce0511 100644 (file)
@@ -10,7 +10,6 @@ struct tree {
 static unsigned char tree1left[32];
 static unsigned char tree1right[32];
 static struct tree tree1 = { 0, tree1left, tree1right };
-static unsigned char tree1bound;
 
 static unsigned char tree2left[8];
 static unsigned char tree2right[8];
@@ -26,10 +25,10 @@ void
 maketree1()
 {
     int i, nbits, x;
+    unsigned char tree1bound;
     unsigned char mindepth;
     unsigned char table1[32];
 
-
     tree1bound = getbits(5);
     mindepth = getbits(3);
     if (mindepth == 0) {
@@ -51,15 +50,8 @@ void
 maketree2(int tree2bound) /* in use: 5 <= tree2bound <= 8 */
 {
     int i, count, index;
-    unsigned char mindepth;
     unsigned char table2[8];
 
-    if (tree1bound < 10)
-        return;
-
-    if (tree1bound == 29 && mindepth == 0)
-        return;
-
     for (i = 0; i < 8; i++)
         table2[i] = 0;
     for (i = 0; i < tree2bound; i++)
@@ -78,8 +70,7 @@ maketree2(int tree2bound) /* in use: 5 <= tree2bound <= 8 */
         tree_setsingle(&tree2, index);
     }
     else if (count > 1) {
-        mindepth = 1;
-        tree_rebuild(&tree2, tree2bound, mindepth, 7, table2);
+        tree_rebuild(&tree2, tree2bound, 1, 7, table2);
     }
     // Note: count == 0 is possible!
     //       Excluding that possibility was a bug in version 1.