aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2019-10-07 08:28:01 +0000
committerpracticalswift <practicalswift@users.noreply.github.com>2019-10-07 08:48:35 +0000
commitffa22212560c9e7a8692cb8982d9b3b507ee9af1 (patch)
tree156ec3bb70eff63734d42f87b491c99cf2359c75 /src/test/fuzz
parent7b701fef58f627956d597817a1f9422edd890cdc (diff)
tests: Pass fuzzing inputs as constant references
Diffstat (limited to 'src/test/fuzz')
-rw-r--r--src/test/fuzz/deserialize.cpp2
-rw-r--r--src/test/fuzz/fuzz.cpp3
-rw-r--r--src/test/fuzz/fuzz.h2
-rw-r--r--src/test/fuzz/script_flags.cpp2
4 files changed, 5 insertions, 4 deletions
diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp
index 9364ac4a32..3a74143dc2 100644
--- a/src/test/fuzz/deserialize.cpp
+++ b/src/test/fuzz/deserialize.cpp
@@ -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 {
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
index 0709da5563..cfa160dde2 100644
--- a/src/test/fuzz/fuzz.cpp
+++ b/src/test/fuzz/fuzz.cpp
@@ -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;
}
diff --git a/src/test/fuzz/fuzz.h b/src/test/fuzz/fuzz.h
index 4e009d9b54..573bd572db 100644
--- a/src/test/fuzz/fuzz.h
+++ b/src/test/fuzz/fuzz.h
@@ -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
diff --git a/src/test/fuzz/script_flags.cpp b/src/test/fuzz/script_flags.cpp
index 9b90d66755..0bf5cd5c72 100644
--- a/src/test/fuzz/script_flags.cpp
+++ b/src/test/fuzz/script_flags.cpp
@@ -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 {