[arith_uint256] Do not destroy *this content if passed-in operator may reference it
This commit is contained in:
parent
bf3353de90
commit
08b17def58
1 changed files with 4 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue