Skip to content

Commit

Permalink
Fix potential null reference in ThreadLocalData::RunDestructors on Wi…
Browse files Browse the repository at this point in the history
…ndows
  • Loading branch information
clarkezone committed Jul 11, 2018
1 parent 7aae795 commit 42f67a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion runtime/vm/os_thread_win.cc
Expand Up @@ -604,7 +604,12 @@ void ThreadLocalData::RemoveThreadLocal(ThreadLocalKey key) {
// This function is executed on the thread that is exiting. It is invoked
// by |OnDartThreadExit| (see below for notes on TLS destructors on Windows).
void ThreadLocalData::RunDestructors() {
ASSERT(thread_locals_ != NULL);
// Because DLL_THREAD_DETACH is hooked on DLL load, if an OS thread is created and exists outside of the Dart context
// before ThreadLocalData::InitOnce has been called by Dart,
// RunDestructors will be called anyway hence need a null reference check.
if(thread_locals_ == NULL) {
return;
}
ASSERT(mutex_ != NULL);
MutexLocker ml(mutex_, false);
for (intptr_t i = 0; i < thread_locals_->length(); i++) {
Expand Down

0 comments on commit 42f67a7

Please sign in to comment.