Merge pull request #5587 from slashdevteam/thread_terminate

Fix fatal parameter error when deleting/terminating Thread object
pull/5723/head
Martin Kojtal 2017-12-20 14:49:57 +00:00 committed by GitHub
commit 6776cb726b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;