Skip to content

Commit

Permalink
Bug #114, CRT DllMain DLL_THREAD_DETACH期间PTD释放逻辑发生Fls野指针
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Sep 9, 2024
1 parent 8a5483e commit 146f311
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Thunks/api-ms-win-core-fibers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ namespace YY::Thunks::Fallback

__try
{
if (_pfnCallback && _FlsData.lpFlsData)
if (_pfnCallback)
{
_pfnCallback(_FlsData.lpFlsData);
auto _pFlsData = (void*)InterlockedExchange(reinterpret_cast<size_t*>(&_FlsData.lpFlsData), 0);
if (_pFlsData)
{
_pfnCallback(_pFlsData);
}
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
Expand All @@ -121,6 +125,7 @@ namespace YY::Thunks::Fallback
}

s_pFlsDataBlock->Release();
s_pFlsDataBlock = nullptr;
}
}

Expand Down

0 comments on commit 146f311

Please sign in to comment.