Fix ASAN static initialization order fiasco

See here for more details
https://github.com/google/sanitizers/wiki/AddressSanitizerInitializationOrderFiasco

Use the "Construct On First Use" idiom from
https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Construct_On_First_Use
This commit is contained in:
Eric Kilmer 2023-05-24 19:03:25 -04:00
parent 6d6d0317e2
commit 1c2323cad3
No known key found for this signature in database
GPG key ID: 504CA431CF70054B
2 changed files with 8 additions and 5 deletions

View file

@ -18,8 +18,6 @@
namespace ghidra {
vector<UnitTest *> UnitTest::tests;
/// Run all the tests unless a non-empty set of names is passed in.
/// In which case, only the named tests in the set are run.
/// \param testNames is the set of names
@ -30,7 +28,7 @@ int UnitTest::run(set<string> &testNames)
int total = 0;
int passed = 0;
for(auto &t : UnitTest::tests) {
for(auto &t : UnitTest::tests()) {
if (testNames.size() > 0 && testNames.find(t->name) == testNames.end()) {
continue;
}