Add .gitignore .
[bigint/bigint.git] / BigUnsigned.cc
index 33fe0af..ad96026 100644 (file)
@@ -562,8 +562,9 @@ void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
        * amusing story of this section of code.
        */
        Index origLen = len; // Save real length.
+       // 2006.05.03: Copy the number and then change the length!
+       allocateAndCopy(len + 1); // Get the space.
        len++; // Increase the length.
-       allocateAndCopy(len); // Get the space.
        blk[origLen] = 0; // Zero the extra block.
        
        // work2 holds part of the result of a subtraction; see above.
@@ -730,7 +731,7 @@ void BigUnsigned::bitXor(const BigUnsigned &a, const BigUnsigned &b) {
                a2 = &b;
                b2 = &a;
        }
-       allocate(b2->len);
+       allocate(a2->len);
        for (i = 0; i < b2->len; i++)
                blk[i] = a2->blk[i] ^ b2->blk[i];
        for (; i < a2->len; i++)