Skip to content

Commit 172ca3f

Browse files
committed
Fix use-after-free in task_wait_event::signal
1 parent 2af276d commit 172ca3f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/task_wait_event.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ class task_wait_event {
9797
{
9898
std::unique_lock<std::mutex> lock(mutex());
9999
event_mask |= event;
100-
lock.unlock();
100+
101+
// This must be done while holding the lock otherwise we may end up with
102+
// a use-after-free due to a race with wait().
101103
cond().notify_one();
104+
lock.unlock();
102105
}
103106
};
104107

0 commit comments

Comments
 (0)