Skip to content

Commit bc3919a

Browse files
committed
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.
1 parent 8aa69f8 commit bc3919a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/global.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ git_global_st *git__global_state(void)
203203
if (!ptr)
204204
return NULL;
205205

206-
git_buf_init(&ptr->error_buf, 0);
206+
if (git_buf_init(&ptr->error_buf, 0) < 0)
207+
return NULL;
207208

208209
FlsSetValue(_fls_index, ptr);
209210
return ptr;
@@ -289,7 +290,9 @@ git_global_st *git__global_state(void)
289290
if (!ptr)
290291
return NULL;
291292

292-
git_buf_init(&ptr->error_buf, 0);
293+
if (git_buf_init(&ptr->error_buf, 0) < 0)
294+
return NULL;
295+
293296
pthread_setspecific(_tls_key, ptr);
294297
return ptr;
295298
}

0 commit comments

Comments
 (0)