From 3c51f3ab1e3c37ca93df73b7c38ca3c555b04e86 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 29 Sep 2021 17:58:47 +0200 Subject: [PATCH] Merge bitcoin/bitcoin#23064: fuzz: Fix memory leak in system fuzz target aaaa37abbab69fe1fdc2d332bbaf6ecce0c5cc00 fuzz: Fix memory leak in system fuzz target (MarcoFalke) Pull request description: Might fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36906 To test: ``` $ FUZZ=system valgrind --tool=massif ./src/test/fuzz/fuzz ../btc_qa_assets/fuzz_seed_corpus/system/ ^C $ massif-visualizer ./massif.out.952024 ``` ACKs for top commit: practicalswift: cr ACK aaaa37abbab69fe1fdc2d332bbaf6ecce0c5cc00 Tree-SHA512: 6aa47ea12ec76133ae326ed41c31414d7a418abe1f28b05f698e9bb5439bbe26b814c4827999b15b77b47608dbc71c9b35789d0b84e25f56928381d06d6460e5 --- src/test/fuzz/system.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/fuzz/system.cpp b/src/test/fuzz/system.cpp index 8a77e46d4f..a593cfbae3 100644 --- a/src/test/fuzz/system.cpp +++ b/src/test/fuzz/system.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -12,6 +13,11 @@ #include namespace { +void initialize_system() +{ + static const auto testing_setup = MakeNoLogFileContext<>(); +} + std::string GetArgumentName(const std::string& name) { size_t idx = name.find('='); @@ -20,9 +26,8 @@ std::string GetArgumentName(const std::string& name) } return name.substr(0, idx); } -} // namespace -FUZZ_TARGET(system) +FUZZ_TARGET_INIT(system, initialize_system) { FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); ArgsManager args_manager{}; @@ -114,3 +119,4 @@ FUZZ_TARGET(system) (void)HelpRequested(args_manager); } +} // namespace