mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
util: Change TraceThread's "name" type: "const char*" -> "const std::string" (#3609)
Having "const char*" leads to undefined behaviour if the "const char*" is deallocated before the thread used it. Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
parent
a170c649b8
commit
f425316eed
@ -433,9 +433,9 @@ void RenameThreadPool(ctpl::thread_pool& tp, const char* baseName);
|
||||
/**
|
||||
* .. and a wrapper that just calls func once
|
||||
*/
|
||||
template <typename Callable> void TraceThread(const char* name, Callable func)
|
||||
template <typename Callable> void TraceThread(const std::string name, Callable func)
|
||||
{
|
||||
std::string s = strprintf("dash-%s", name);
|
||||
std::string s = "dash-" + name;
|
||||
RenameThread(s.c_str());
|
||||
try
|
||||
{
|
||||
@ -449,7 +449,7 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
|
||||
throw;
|
||||
}
|
||||
catch (...) {
|
||||
PrintExceptionContinue(std::current_exception(), name);
|
||||
PrintExceptionContinue(std::current_exception(), name.c_str());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user