Merge #17069: tests: Pass fuzzing inputs as constant references

ffa2221256 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 https://github.com/bitcoin/bitcoin/pull/17009#discussion_r331502028.

ACKs for top commit:
  MarcoFalke:
    ACK ffa2221256

Tree-SHA512: c1e3d6658a0b45cece2ed7e7c2ba1b78cdb71a03767231de7e5c212575117a4e2b70079265c745963480d7fcd4d9706561a2325b8c993b94eec33268ad4b293c
pull/764/head
MarcoFalke 5 years ago
commit febc31c641
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25

@ -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 {

@ -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;
}

@ -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

@ -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 {

Loading…
Cancel
Save