diff options
author | xyb <xyb@xyb.name> | 2019-11-16 17:13:52 (GMT) |
---|---|---|
committer | xyb <xyb@xyb.name> | 2019-11-16 17:13:52 (GMT) |
commit | dcdb65065f41aad2b706a945108f9d02b381a392 (patch) | |
tree | 7da3189d4f1ea109d188dd76922b5e1f8901e125 /googletest | |
parent | 703bd9caab50b139428cea1aaff9974ebee5742e (diff) | |
download | googletest-dcdb65065f41aad2b706a945108f9d02b381a392.zip googletest-dcdb65065f41aad2b706a945108f9d02b381a392.tar.gz googletest-dcdb65065f41aad2b706a945108f9d02b381a392.tar.bz2 |
Fix internal memory leak in Windows _Crt report.refs/pull/2571/headrefs/pull/2570/head
We use "MemoryIsNotDeallocated" to aovid internal expected leak reported
in Windows _Crt report, like:
{
#ifdef _MSC_VER
MemoryIsNotDeallocated memory_is_not_deeallocated;
#endif
static ThreadIdToThreadLocals* map = new
ThreadIdToThreadLocals();
return map;
}
But int the above code, only "new ThreadIdToThreadLocals()" is
protected, if we invoke "insert()" function of the return value,
the memory allocated in "insert()" will be reported to _Crt report
also. This change try to fix this issue.
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/src/gtest-port.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index fc5ba6b..71909c3 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -536,6 +536,9 @@ class ThreadLocalRegistryImpl { // Returns a value that can be used to identify the thread from other threads. static ThreadLocalValueHolderBase* GetValueOnCurrentThread( const ThreadLocalBase* thread_local_instance) { +#ifdef _MSC_VER + MemoryIsNotDeallocated memory_is_not_deallocated; +#endif // _MSC_VER DWORD current_thread = ::GetCurrentThreadId(); MutexLock lock(&mutex_); ThreadIdToThreadLocals* const thread_to_thread_locals = |