Skip to content

Commit

Permalink
tests: Pass fuzzing inputs as constant references
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift committed Oct 7, 2019
1 parent 7b701fe commit ffa2221
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/test/fuzz/deserialize.cpp
Expand Up @@ -23,7 +23,7 @@

#include <test/fuzz/fuzz.h>

void test_one_input(std::vector<uint8_t> buffer)
void test_one_input(const std::vector<uint8_t>& buffer)
{
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
try {
Expand Down
3 changes: 2 additions & 1 deletion src/test/fuzz/fuzz.cpp
Expand Up @@ -30,7 +30,8 @@ static void initialize()
// This function is used by libFuzzer
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
test_one_input(std::vector<uint8_t>(data, data + size));
const std::vector<uint8_t> input(data, data + size);
test_one_input(input);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/fuzz.h
Expand Up @@ -9,6 +9,6 @@
#include <vector>


void test_one_input(std::vector<uint8_t> buffer);
void test_one_input(const std::vector<uint8_t>& buffer);

#endif // BITCOIN_TEST_FUZZ_FUZZ_H
2 changes: 1 addition & 1 deletion src/test/fuzz/script_flags.cpp
Expand Up @@ -11,7 +11,7 @@
/** Flags that are not forbidden by an assert */
static bool IsValidFlagCombination(unsigned flags);

void test_one_input(std::vector<uint8_t> buffer)
void test_one_input(const std::vector<uint8_t>& buffer)
{
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
try {
Expand Down

0 comments on commit ffa2221

Please sign in to comment.