Skip to content

Commit 3db98b5

Browse files
marogiadbridge
authored andcommitted
Fatal parameter error when deleting/terminating Thread object
Call to osThreadTerminate is guarded by local_id check, to avoid parameter error fault when deleting or terminating Thread object that was not started.
1 parent 190bd25 commit 3db98b5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rtos/Thread.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ osStatus Thread::terminate() {
129129
_tid = (osThreadId_t)NULL;
130130
if (!_finished) {
131131
_finished = true;
132-
ret = osThreadTerminate(local_id);
132+
// if local_id == 0 Thread was not started in first place
133+
// and does not have to be terminated
134+
if(local_id != 0) {
135+
ret = osThreadTerminate(local_id);
136+
}
133137
}
134138
_mutex.unlock();
135139
return ret;

0 commit comments

Comments
 (0)