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.
pull/5587/head
Maciej Rogozinski 2017-11-25 18:09:37 +01:00
parent 4e222952d7
commit c721ed8966
1 changed files with 5 additions and 1 deletions

View File

@ -129,7 +129,11 @@ osStatus Thread::terminate() {
_tid = (osThreadId_t)NULL;
if (!_finished) {
_finished = true;
ret = osThreadTerminate(local_id);
// if local_id == 0 Thread was not started in first place
// and does not have to be terminated
if(local_id != 0) {
ret = osThreadTerminate(local_id);
}
}
_mutex.unlock();
return ret;