From db4bd32cc31789fc017f5db0b86a69ee43e41575 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 23 Oct 2019 21:46:53 +0000 Subject: [PATCH] tests: Skip unnecessary fuzzer initialisation. Hold ECCVerifyHandle only when needed. --- src/test/fuzz/deserialize.cpp | 7 +++++++ src/test/fuzz/fuzz.cpp | 13 +++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp index 3a6876ad393..bcd8691359f 100644 --- a/src/test/fuzz/deserialize.cpp +++ b/src/test/fuzz/deserialize.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,12 @@ #include +void initialize() +{ + // Fuzzers using pubkey must hold an ECCVerifyHandle. + static const auto verify_handle = MakeUnique(); +} + void test_one_input(const std::vector& buffer) { CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index a8a108cd186..44256ce867b 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -4,11 +4,9 @@ #include +#include #include - -#include -#include - +#include static bool read_stdin(std::vector& data) { @@ -23,10 +21,8 @@ static bool read_stdin(std::vector& data) } // Default initialization: Override using a non-weak initialize(). -__attribute__((weak)) -void initialize() +__attribute__((weak)) void initialize() { - const static auto verify_handle = MakeUnique(); } // This function is used by libFuzzer @@ -50,7 +46,8 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) // the main(...) function. __attribute__((weak)) #endif -int main(int argc, char **argv) +int +main(int argc, char** argv) { initialize(); #ifdef __AFL_INIT