Skip to content

Commit febc31c

Browse files
author
MarcoFalke
committed
Merge #17069: tests: Pass fuzzing inputs as constant references
ffa2221 tests: Pass fuzzing inputs as constant references (practicalswift) Pull request description: Pass fuzzing inputs as constant references. Split out from #17009 as suggested by MarcoFalke in bitcoin/bitcoin#17009 (comment). ACKs for top commit: MarcoFalke: ACK ffa2221 Tree-SHA512: c1e3d6658a0b45cece2ed7e7c2ba1b78cdb71a03767231de7e5c212575117a4e2b70079265c745963480d7fcd4d9706561a2325b8c993b94eec33268ad4b293c
2 parents 7b701fe + ffa2221 commit febc31c

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

src/test/fuzz/deserialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include <test/fuzz/fuzz.h>
2525

26-
void test_one_input(std::vector<uint8_t> buffer)
26+
void test_one_input(const std::vector<uint8_t>& buffer)
2727
{
2828
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
2929
try {

src/test/fuzz/fuzz.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ static void initialize()
3030
// This function is used by libFuzzer
3131
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
3232
{
33-
test_one_input(std::vector<uint8_t>(data, data + size));
33+
const std::vector<uint8_t> input(data, data + size);
34+
test_one_input(input);
3435
return 0;
3536
}
3637

src/test/fuzz/fuzz.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
#include <vector>
1010

1111

12-
void test_one_input(std::vector<uint8_t> buffer);
12+
void test_one_input(const std::vector<uint8_t>& buffer);
1313

1414
#endif // BITCOIN_TEST_FUZZ_FUZZ_H

src/test/fuzz/script_flags.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/** Flags that are not forbidden by an assert */
1212
static bool IsValidFlagCombination(unsigned flags);
1313

14-
void test_one_input(std::vector<uint8_t> buffer)
14+
void test_one_input(const std::vector<uint8_t>& buffer)
1515
{
1616
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
1717
try {

0 commit comments

Comments
 (0)