Fixed memory leaks for non-solaris compilers.

This commit is contained in:
Daniel Marjamäki 2014-11-26 16:13:40 +01:00
parent 0913a51ccd
commit 465555e39d
1 changed files with 8 additions and 0 deletions

View File

@ -42,7 +42,15 @@ void Check::reportError(const ErrorLogger::ErrorMessage &errmsg)
{
std::cout << errmsg.toXML(true, 1) << std::endl;
}
std::list<Check *> &Check::instances() {
#ifdef __SVR4
// Under Solaris, destructors are called in wrong order which causes a segmentation fault.
// This fix ensures pointer remains valid and reachable until program terminates.
static std::list<Check *> *_instances= new std::list<Check *>;
return *_instances;
#else
static std::list<Check *> _instances;
return _instances;
#endif
}