File tree Expand file tree Collapse file tree
include/bitcoin/database/tables/caches Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,11 +87,19 @@ struct multisig
8787 using namespace system ;
8888 const auto m = sigs.size ();
8989 const auto n = keys.size ();
90+ if (is_subtract_overflow (n, m))
91+ return {};
9092
91- BC_ASSERT (!is_subtract_overflow (n, m));
92- BC_ASSERT (!is_add_overflow (n - m, one));
93- BC_ASSERT (!is_multiply_overflow (m, add1 (n - m)));
94- return possible_narrow_cast<link::integer>(m * add1 (n - m));
93+ const auto gap = n - m;
94+ if (is_add_overflow (gap, one))
95+ return {};
96+
97+ const auto sum = add1 (gap);
98+ if (is_multiply_overflow (m, sum))
99+ return {};
100+
101+ // Terminal count fails the write attempt, so to_data() is guarded.
102+ return possible_narrow_cast<link::integer>(m * sum);
95103 }
96104
97105 inline bool to_data (flipper& sink) const NOEXCEPT
You can’t perform that action at this time.
0 commit comments