Merge pull request #6382 from lioncash/null

k_thread: Move dereference after null check in Initialize()
This commit is contained in:
bunnei 2021-05-29 01:17:28 -07:00 committed by GitHub
commit cdabc9064b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,13 +168,13 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s
std::memset(static_cast<void*>(std::addressof(GetStackParameters())), 0, std::memset(static_cast<void*>(std::addressof(GetStackParameters())), 0,
sizeof(StackParameters)); sizeof(StackParameters));
// Set parent, if relevant.
if (owner != nullptr) {
// Setup the TLS, if needed. // Setup the TLS, if needed.
if (type == ThreadType::User) { if (type == ThreadType::User) {
tls_address = owner->CreateTLSRegion(); tls_address = owner->CreateTLSRegion();
} }
// Set parent, if relevant.
if (owner != nullptr) {
parent = owner; parent = owner;
parent->Open(); parent->Open();
parent->IncrementThreadCount(); parent->IncrementThreadCount();