summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-06-07 12:55:17 +0200
committerPatrick Steinhardt <ps@pks.im>2016-06-07 12:55:17 +0200
commit432af52b37a10aec278bb322c6805967cca5fc49 (patch)
tree3677925a2ad2bc001217f7145ea5429839a6a653
parent292c60275e98c15fcbbc295b44c306d7b2ecb6af (diff)
downloadlibgit2-432af52b37a10aec278bb322c6805967cca5fc49.tar.gz
global: clean up crt only after freeing tls data
The thread local storage is used to hold some global state that is dynamically allocated and should be freed upon exit. On Windows, we clean up the C run-time right after execution of registered shutdown callbacks and before cleaning up the TLS. When we clean up the CRT, we also cause it to analyze for memory leaks. As we did not free the TLS yet this will lead to false positives. Fix the issue by first freeing the TLS and cleaning up the CRT only afterwards.
-rw-r--r--src/global.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/global.c b/src/global.c
index e1836ee0f..32e497507 100644
--- a/src/global.c
+++ b/src/global.c
@@ -87,11 +87,6 @@ static void shutdown_common(void)
git__free(git__user_agent);
git__free(git__ssl_ciphers);
-
-#if defined(GIT_MSVC_CRTDBG)
- git_win32__crtdbg_stacktrace_cleanup();
- git_win32__stack_cleanup();
-#endif
}
/**
@@ -183,6 +178,11 @@ int git_libgit2_shutdown(void)
TlsFree(_tls_index);
git_mutex_free(&git__mwindow_mutex);
+
+#if defined(GIT_MSVC_CRTDBG)
+ git_win32__crtdbg_stacktrace_cleanup();
+ git_win32__stack_cleanup();
+#endif
}
/* Exit the lock */