Skip to content

Commit 3737126

Browse files
Mark CheckTxInputs [[nodiscard]] (out-param txfee only set if call is successful). Avoid UUM in fuzzing harness coins_view.
1 parent 8600934 commit 3737126

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/consensus/tx_verify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Consensus {
2424
* @param[out] txfee Set to the transaction fee if successful.
2525
* Preconditions: tx.IsCoinBase() is false.
2626
*/
27-
bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
27+
[[nodiscard]] bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
2828
} // namespace Consensus
2929

3030
/** Auxiliary functions for transaction validation (ideally should not be exposed) */

src/test/fuzz/coins_view.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
236236
// It is not allowed to call CheckTxInputs if CheckTransaction failed
237237
return;
238238
}
239-
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
240-
assert(MoneyRange(tx_fee_out));
239+
if (Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out)) {
240+
assert(MoneyRange(tx_fee_out));
241+
}
241242
},
242243
[&] {
243244
const CTransaction transaction{random_mutable_transaction};

0 commit comments

Comments
 (0)