Skip to content

Commit 0faf9ab

Browse files
authored
Bugfix: Prevent access to iterator when block/unblock is called by an unregistered thread. (#15)
1 parent a04ae1f commit 0faf9ab

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/serial/SerialDispatcher.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ void SerialDispatcher::block()
153153
{
154154
mbed::ScopedLock<rtos::Mutex> lock(_mutex);
155155
auto iter = findThreadCustomerDataById(rtos::ThisThread::get_id());
156+
if (iter == std::end(_thread_customer_list)) return;
156157
iter->block_tx_buffer = true;
157158
}
158159

159160
void SerialDispatcher::unblock()
160161
{
161162
mbed::ScopedLock<rtos::Mutex> lock(_mutex);
162163
auto iter = findThreadCustomerDataById(rtos::ThisThread::get_id());
164+
if (iter == std::end(_thread_customer_list)) return;
163165
iter->block_tx_buffer = false;
164166
_cond.notify_one();
165167
}

0 commit comments

Comments
 (0)