Skip to content

Commit a2bc330

Browse files
committed
feefrac test: avoid integer overflow (bugfix)
1 parent cfe025f commit a2bc330

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/test/fuzz/feefrac.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ FUZZ_TARGET(feefrac_mul_div)
220220
assert(res == res_fee);
221221

222222
// Compare approximately with CFeeRate.
223-
if (mul64 <= std::numeric_limits<int64_t>::max() / 1000 &&
224-
mul64 >= std::numeric_limits<int64_t>::min() / 1000 &&
225-
quot_abs <= arith_uint256{std::numeric_limits<int64_t>::max() / 1000}) {
223+
if (mul64 < std::numeric_limits<int64_t>::max() / 1000 &&
224+
mul64 > std::numeric_limits<int64_t>::min() / 1000 &&
225+
quot_abs < arith_uint256{std::numeric_limits<int64_t>::max() / 1000}) {
226226
CFeeRate feerate(mul64, (uint32_t)div);
227227
CAmount feerate_fee{feerate.GetFee(mul32)};
228228
auto allowed_gap = static_cast<int64_t>(mul32 / 1000 + 3 + round_down);

0 commit comments

Comments
 (0)