Skip to content

Commit

Permalink
Fix for Issue Item Number: 10098
Browse files Browse the repository at this point in the history
  • Loading branch information
jlddodger authored and KindDragon committed Apr 29, 2013
1 parent 8d636a4 commit b3c8276
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions vld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,18 +975,31 @@ tls_t* VisualLeakDetector::getTls ()
assert(GetLastError() == ERROR_SUCCESS);

if (tls == NULL) {
// This thread's thread local storage structure has not been allocated.
tls = new tls_t;
DWORD threadId = GetCurrentThreadId();

{
CriticalSectionLocker cs(m_tlsLock);
TlsMap::Iterator it = m_tlsMap->find(threadId);
if(it == m_tlsMap->end()) {
// This thread's thread local storage structure has not been allocated.
tls = new tls_t;

// Add this thread's TLS to the TlsSet.
m_tlsMap->insert(threadId,tls);
}
else {
// Already had a thread with this ID
tls = (*it).second;
}
}

TlsSetValue(m_tlsIndex, tls);
ZeroMemory(&tls->context, sizeof(tls->context));
tls->flags = 0x0;
tls->oldFlags = 0x0;
tls->threadId = GetCurrentThreadId();
tls->threadId = threadId;
tls->ppCallStack = NULL;

// Add this thread's TLS to the TlsSet.
CriticalSectionLocker cs(m_tlsLock);
m_tlsMap->insert(tls->threadId,tls);
tls->blockProcessed = FALSE;
}

return tls;
Expand Down

0 comments on commit b3c8276

Please sign in to comment.