mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-10-17 05:41:41 +02:00
Merge pull request #44 from fireice-uk/fix-uninit-access
Make sure all singletons are set to null and make env a global ptr
This commit is contained in:
@@ -65,7 +65,7 @@ __declspec(dllexport)
|
||||
#endif
|
||||
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
|
||||
{
|
||||
environment::inst() = env;
|
||||
environment::inst(&env);
|
||||
return amd::minethd::thread_starter(threadOffset, pWork);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -112,7 +112,7 @@ __declspec(dllexport)
|
||||
#endif
|
||||
std::vector<iBackend*>* xmrstak_start_backend(uint32_t threadOffset, miner_work& pWork, environment& env)
|
||||
{
|
||||
environment::inst() = env;
|
||||
environment::inst(&env);
|
||||
return nvidia::minethd::thread_starter(threadOffset, pWork);
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
@@ -12,35 +12,30 @@ struct params;
|
||||
|
||||
struct environment
|
||||
{
|
||||
static inline environment& inst(environment* init = nullptr)
|
||||
{
|
||||
static environment* env = nullptr;
|
||||
|
||||
static environment& inst()
|
||||
{
|
||||
static environment env;
|
||||
return env;
|
||||
}
|
||||
|
||||
environment& operator=(const environment& env)
|
||||
{
|
||||
this->pPrinter = env.pPrinter;
|
||||
this->pglobalStates = env.pglobalStates;
|
||||
this->pJconfConfig = env.pJconfConfig;
|
||||
this->pExecutor = env.pExecutor;
|
||||
this->pParams = env.pParams;
|
||||
return *this;
|
||||
if(env == nullptr)
|
||||
{
|
||||
if(init == nullptr)
|
||||
env = new environment;
|
||||
else
|
||||
env = init;
|
||||
}
|
||||
|
||||
return *env;
|
||||
}
|
||||
|
||||
|
||||
environment() : pPrinter(nullptr), pglobalStates(nullptr)
|
||||
environment()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
printer* pPrinter;
|
||||
globalStates* pglobalStates;
|
||||
jconf* pJconfConfig;
|
||||
executor* pExecutor;
|
||||
params* pParams;
|
||||
|
||||
printer* pPrinter = nullptr;
|
||||
globalStates* pglobalStates = nullptr;
|
||||
jconf* pJconfConfig = nullptr;
|
||||
executor* pExecutor = nullptr;
|
||||
params* pParams = nullptr;
|
||||
};
|
||||
|
||||
} // namepsace xmrstak
|
||||
|
||||
Reference in New Issue
Block a user