Fix integer overflow due to large unsigned cpp_int

This commit is contained in:
Bhargava Shastry 2020-12-14 11:20:31 +01:00
parent d83ce0bcdd
commit 39f1893956

View File

@ -69,7 +69,7 @@ static V integerValue(unsigned _counter)
V value = V(
u256(solidity::util::keccak256(solidity::util::h256(_counter))) % u256(boost::math::tools::max_value<V>())
);
if (value % 2 == 0)
if (boost::multiprecision::is_signed_number<V>::value && value % 2 == 0)
return value * (-1);
else
return value;