Skip to content

Commit fae4ee5

Browse files
author
MarcoFalke
committed
fuzz: Add missing CheckTransaction before CheckTxInputs
1 parent faacb7e commit fae4ee5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/fuzz/coins_view.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <chainparams.h>
77
#include <chainparamsbase.h>
88
#include <coins.h>
9+
#include <consensus/tx_check.h>
910
#include <consensus/tx_verify.h>
1011
#include <consensus/validation.h>
1112
#include <key.h>
@@ -230,6 +231,11 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
230231
// consensus/tx_verify.cpp:171: bool Consensus::CheckTxInputs(const CTransaction &, TxValidationState &, const CCoinsViewCache &, int, CAmount &): Assertion `!coin.IsSpent()' failed.
231232
return;
232233
}
234+
TxValidationState dummy;
235+
if (!CheckTransaction(transaction, dummy)) {
236+
// It is not allowed to call CheckTxInputs if CheckTransaction failed
237+
return;
238+
}
233239
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
234240
assert(MoneyRange(tx_fee_out));
235241
},

0 commit comments

Comments
 (0)