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
This commit is contained in:
MarcoFalke 2021-09-29 17:58:47 +02:00 committed by Vijay
parent 6d426515a5
commit 3c51f3ab1e
No known key found for this signature in database
GPG Key ID: 47820EC166FDF549

View File

@ -5,6 +5,7 @@
#include <test/fuzz/FuzzedDataProvider.h> #include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h> #include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h> #include <test/fuzz/util.h>
#include <test/util/setup_common.h>
#include <util/system.h> #include <util/system.h>
#include <cstdint> #include <cstdint>
@ -12,6 +13,11 @@
#include <vector> #include <vector>
namespace { namespace {
void initialize_system()
{
static const auto testing_setup = MakeNoLogFileContext<>();
}
std::string GetArgumentName(const std::string& name) std::string GetArgumentName(const std::string& name)
{ {
size_t idx = name.find('='); size_t idx = name.find('=');
@ -20,9 +26,8 @@ std::string GetArgumentName(const std::string& name)
} }
return name.substr(0, idx); return name.substr(0, idx);
} }
} // namespace
FUZZ_TARGET(system) FUZZ_TARGET_INIT(system, initialize_system)
{ {
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
ArgsManager args_manager{}; ArgsManager args_manager{};
@ -114,3 +119,4 @@ FUZZ_TARGET(system)
(void)HelpRequested(args_manager); (void)HelpRequested(args_manager);
} }
} // namespace