diff options
| author | Karl-Johan Alm <[email protected]> | 2018-02-26 15:34:53 +0900 |
|---|---|---|
| committer | Karl-Johan Alm <[email protected]> | 2018-03-01 11:49:35 +0900 |
| commit | 08b17def58d4135c1dc904a6068670c3c92a3768 (patch) | |
| tree | 0eb4ead2cdf209138f8433b020974688f65dea20 | |
| parent | Merge #12287: Optimise lock behaviour for GuessVerificationProgress() (diff) | |
| download | discoin-08b17def58d4135c1dc904a6068670c3c92a3768.tar.xz discoin-08b17def58d4135c1dc904a6068670c3c92a3768.zip | |
[arith_uint256] Do not destroy *this content if passed-in operator may reference it
| -rw-r--r-- | src/arith_uint256.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 65de63230..c7ddb17eb 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -69,16 +69,16 @@ base_uint<BITS>& base_uint<BITS>::operator*=(uint32_t b32) template <unsigned int BITS> base_uint<BITS>& base_uint<BITS>::operator*=(const base_uint& b) { - base_uint<BITS> a = *this; - *this = 0; + base_uint<BITS> a; for (int j = 0; j < WIDTH; j++) { uint64_t carry = 0; for (int i = 0; i + j < WIDTH; i++) { - uint64_t n = carry + pn[i + j] + (uint64_t)a.pn[j] * b.pn[i]; - pn[i + j] = n & 0xffffffff; + uint64_t n = carry + a.pn[i + j] + (uint64_t)pn[j] * b.pn[i]; + a.pn[i + j] = n & 0xffffffff; carry = n >> 32; } } + *this = a; return *this; } |