summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-07-11 12:14:26 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-10-11 14:43:37 +0100
commitbc3919abc716088cf7c33bc08d48ee2bc434c398 (patch)
treedf297af7672e78e572cd16a605ed430356e40a7f
parent8aa69f887afaced1389d1ae965d5f313b10da66b (diff)
downloadlibgit2-bc3919abc716088cf7c33bc08d48ee2bc434c398.tar.gz
global init: check error message buffer allocation
Ensure that we can allocate the error message buffer. In keeping with our typical policiess, we allow (small) memory leaks in the case where we're out of memory.
-rw-r--r--src/global.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/global.c b/src/global.c
index 8b16166f2..f67811a95 100644
--- a/src/global.c
+++ b/src/global.c
@@ -203,7 +203,8 @@ git_global_st *git__global_state(void)
if (!ptr)
return NULL;
- git_buf_init(&ptr->error_buf, 0);
+ if (git_buf_init(&ptr->error_buf, 0) < 0)
+ return NULL;
FlsSetValue(_fls_index, ptr);
return ptr;
@@ -289,7 +290,9 @@ git_global_st *git__global_state(void)
if (!ptr)
return NULL;
- git_buf_init(&ptr->error_buf, 0);
+ if (git_buf_init(&ptr->error_buf, 0) < 0)
+ return NULL;
+
pthread_setspecific(_tls_key, ptr);
return ptr;
}