Skip to content

Commit 19007b1

Browse files
committed
alloc: don't overwrite allocator during init if set
If the allocator has been set before we the library is initialised, we would replace that setting with the standard allocator contrary to the user's wishes.
1 parent 2510268 commit 19007b1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/alloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ git_allocator git__allocator;
1717

1818
int git_allocator_global_init(void)
1919
{
20+
/*
21+
* We don't want to overwrite any allocator which has been set before
22+
* the init function is called.
23+
*/
24+
if (git__allocator.gmalloc != NULL)
25+
return 0;
26+
2027
#if defined(GIT_MSVC_CRTDBG)
2128
return git_win32_crtdbg_init_allocator(&git__allocator);
2229
#else

0 commit comments

Comments
 (0)