X-Git-Url: https://mattmccutchen.net/bigint/bigint.git/blobdiff_plain/26a5f52b24d9c9733139a6cf29647f1de7915a56..a82332d03045a6029b01b694cdca1acdb85ecadf:/BigUnsigned.cc diff --git a/BigUnsigned.cc b/BigUnsigned.cc index 33fe0af..ad96026 100644 --- a/BigUnsigned.cc +++ b/BigUnsigned.cc @@ -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++)