Skip to content

Commit cf83b82

Browse files
author
MarcoFalke
committed
fuzz: Limit toxic test globals to their respective scope
1 parent e2d4e67 commit cf83b82

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/test/fuzz/script_assets_test_minimizer.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ unsigned int ParseScriptFlags(const std::string& str)
133133
std::vector<std::string> words;
134134
boost::algorithm::split(words, str, boost::algorithm::is_any_of(","));
135135

136-
for (const std::string& word : words)
137-
{
136+
for (const std::string& word : words) {
138137
auto it = FLAG_NAMES.find(word);
139138
if (it == FLAG_NAMES.end()) throw std::runtime_error("Unknown verification flag " + word);
140139
flags |= it->second;
@@ -186,15 +185,19 @@ void Test(const std::string& str)
186185
}
187186
}
188187

189-
ECCVerifyHandle handle;
190-
191-
} // namespace
188+
void test_init()
189+
{
190+
static ECCVerifyHandle handle;
191+
}
192192

193-
FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, FuzzFrameworkEmptyInitFun, /* hidden */ true)
193+
FUZZ_TARGET_INIT_HIDDEN(script_assets_test_minimizer, test_init, /* hidden */ true)
194194
{
195195
if (buffer.size() < 2 || buffer.back() != '\n' || buffer[buffer.size() - 2] != ',') return;
196196
const std::string str((const char*)buffer.data(), buffer.size() - 2);
197197
try {
198198
Test(str);
199-
} catch (const std::runtime_error&) {}
199+
} catch (const std::runtime_error&) {
200+
}
200201
}
202+
203+
} // namespace

0 commit comments

Comments
 (0)