Commit ee3baed1788f3e94ab6cfd550ee35667af764f45

Carlos Martín Nieto 2018-07-15T19:28:22

Merge pull request #4724 from libgit2/cmn/allocator-init-order alloc: don't overwrite allocator during init if set

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/alloc.c b/src/alloc.c
index 35fdd00..d4e6f1e 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -17,6 +17,13 @@ git_allocator git__allocator;
 
 int git_allocator_global_init(void)
 {
+	/*
+	 * We don't want to overwrite any allocator which has been set before
+	 * the init function is called.
+	 */
+	if (git__allocator.gmalloc != NULL)
+		return 0;
+
 #if defined(GIT_MSVC_CRTDBG)
 	return git_win32_crtdbg_init_allocator(&git__allocator);
 #else