Skip to content

Commit 0b8c8ed

Browse files
authored
[lldb] Fix use-after-free in SBMutexTest (llvm#133840)
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.
1 parent b2d272c commit 0b8c8ed

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lldb/unittests/API/SBMutexTest.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ class SBMutexTest : public testing::Test {
3232

3333
TEST_F(SBMutexTest, LockTest) {
3434
lldb::SBTarget target = debugger.GetDummyTarget();
35-
35+
std::atomic<bool> locked = false;
3636
std::future<void> f;
3737
{
38-
std::atomic<bool> locked = false;
3938
lldb::SBMutex lock = target.GetAPIMutex();
4039
std::lock_guard<lldb::SBMutex> lock_guard(lock);
4140
ASSERT_FALSE(locked.exchange(true));

0 commit comments

Comments
 (0)