Skip to content

Commit 432af52

Browse files
committed
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.
1 parent 292c602 commit 432af52

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/global.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ static void shutdown_common(void)
8787

8888
git__free(git__user_agent);
8989
git__free(git__ssl_ciphers);
90-
91-
#if defined(GIT_MSVC_CRTDBG)
92-
git_win32__crtdbg_stacktrace_cleanup();
93-
git_win32__stack_cleanup();
94-
#endif
9590
}
9691

9792
/**
@@ -183,6 +178,11 @@ int git_libgit2_shutdown(void)
183178

184179
TlsFree(_tls_index);
185180
git_mutex_free(&git__mwindow_mutex);
181+
182+
#if defined(GIT_MSVC_CRTDBG)
183+
git_win32__crtdbg_stacktrace_cleanup();
184+
git_win32__stack_cleanup();
185+
#endif
186186
}
187187

188188
/* Exit the lock */

0 commit comments

Comments
 (0)