0
0
mirror of https://github.com/llvm/llvm-project.git synced 2025-04-21 17:16:52 +00:00

[lldb] Fix use-after-free in SBMutexTest ()

The `locked` variable can be accessed from the asynchronous thread until
the call to f.wait() completes. However, the variable is scoped in a
lexical block that ends before that, leading to a use-after-free.
This commit is contained in:
Jonas Devlieghere 2025-03-31 19:36:05 -07:00 committed by GitHub
parent b2d272ccfb
commit 0b8c8ed042
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,10 +32,9 @@ protected:
TEST_F(SBMutexTest, LockTest) {
lldb::SBTarget target = debugger.GetDummyTarget();
std::atomic<bool> locked = false;
std::future<void> f;
{
std::atomic<bool> locked = false;
lldb::SBMutex lock = target.GetAPIMutex();
std::lock_guard<lldb::SBMutex> lock_guard(lock);
ASSERT_FALSE(locked.exchange(true));