mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-15 16:00:44 +02:00
Windows: Avoid a double-free if a thread is terminated twice
Unlikely to show up in any real code, but if an attempt is made to terminate a terminated thread we should handle this gracefully.
This commit is contained in:
1 parent
4df17abea7
commit
8ad1ea499d
2 files changed
+14
-2
No files matched your search
@@ -974,7 +974,13 @@ NTSTATUS ThreadTerm(HANDLE Thread, LONG ExitCode) {
|
||||
|
||||
{
|
||||
std::scoped_lock Lock(ThreadCreationMutex);
|
||||
Threads.erase(ThreadTID);
|
||||
auto it = Threads.find(ThreadTID);
|
||||
if (it == Threads.end()) {
|
||||
// Thread already terminated
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Threads.erase(it);
|
||||
if (StatAllocHandler) {
|
||||
StatAllocHandler->DeallocateSlot(CPUArea.ThreadState()->ThreadStats);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user