mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
fix(thread): 在线程外调用api.id时添加错误检查
添加对current变量的检查,防止在线程外调用api.id时导致空指针异常
This commit is contained in:
@@ -103,6 +103,9 @@ function api.exists(id)
|
||||
end
|
||||
|
||||
function api.id()
|
||||
if not current then
|
||||
error("No current thread - are you calling this outside a thread?")
|
||||
end
|
||||
return current.id
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user