diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-05-04 09:30:58 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-05-04 09:24:17 +0200 |
commit | cf83b82cf04a57223ebed74b8935e56f74ed721b (patch) | |
tree | de91fe471c9bb70cd023c48bdd5f4ab152e1cd37 /src/test | |
parent | e2d4e67a8fccfaebad5accced629711bb6402d3f (diff) |
fuzz: Limit toxic test globals to their respective scope
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/script_assets_test_minimizer.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/fuzz/script_assets_test_minimizer.cpp b/src/test/fuzz/script_assets_test_minimizer.cpp index cec5212f42..a80338b965 100644 --- a/src/test/fuzz/script_assets_test_minimizer.cpp +++ b/src/test/fuzz/script_assets_test_minimizer.cpp @@ -133,8 +133,7 @@ unsigned int ParseScriptFlags(const std::string& str) std::vector<std::string> words; boost::algorithm::split(words, str, boost::algorithm::is_any_of(",")); - for (const std::string& word : words) - { + for (const std::string& word : words) { auto it = FLAG_NAMES.find(word); if (it == FLAG_NAMES.end()) throw std::runtime_error("Unknown verification flag " + word); flags |= it->second; @@ -186,15 +185,19 @@ void Test(const std::string& str) } } -ECCVerifyHandle handle; - -} // namespace +void test_init() +{ + static ECCVerifyHandle handle; +} -FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, FuzzFrameworkEmptyInitFun, /* hidden */ true) +FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, test_init, /* hidden */ true) { if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return; const std::string str((const char*)buffer.data(), buffer.size() - 2); try { Test(str); - } catch (const std::runtime_error&) {} + } catch (const std::runtime_error&) { + } } + +} // namespace |