Skip to content

Commit fa31c4d

Browse files
author
MarcoFalke
committed
fuzz: Avoid OOM in transaction fuzz target
Also fix bug where the json object is reused between two calls.
1 parent d1ae967 commit fa31c4d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/test/fuzz/transaction.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
101101
(void)AreInputsStandard(tx, coins_view_cache);
102102
(void)IsWitnessStandard(tx, coins_view_cache);
103103

104-
UniValue u(UniValue::VOBJ);
105-
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
106-
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
104+
if (tx.GetTotalSize() < 250'000) { // Avoid high memory usage (with msan) due to json encoding
105+
{
106+
UniValue u{UniValue::VOBJ};
107+
TxToUniv(tx, /*block_hash=*/uint256::ZERO, /*entry=*/u);
108+
}
109+
{
110+
UniValue u{UniValue::VOBJ};
111+
TxToUniv(tx, /*block_hash=*/uint256::ONE, /*entry=*/u);
112+
}
113+
}
107114
}

0 commit comments

Comments
 (0)