diff options
author | Russell Belfer <rb@github.com> | 2013-05-31 14:13:11 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-05-31 14:13:11 -0700 |
commit | 1a42dd17eb2c35fa572418f5958595cbe297d229 (patch) | |
tree | f135f3788eb20b5ac100519c41c7525f5f830457 /src/global.c | |
parent | f658dc433cae351e72b1c8b245724eafb43f5844 (diff) | |
download | libgit2-1a42dd17eb2c35fa572418f5958595cbe297d229.tar.gz |
Mutex init can fail
It is obviously quite a serious problem if this happens, but mutex
initialization can fail and we should detect it. It's a bit like
a memory allocation failure, in that you're probably pretty screwed
if this occurs, but at least we'll catch it.
Diffstat (limited to 'src/global.c')
-rw-r--r-- | src/global.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/global.c b/src/global.c index a0571d127..2d40ca2fc 100644 --- a/src/global.c +++ b/src/global.c @@ -61,7 +61,8 @@ int git_threads_init(void) return 0; _tls_index = TlsAlloc(); - git_mutex_init(&git__mwindow_mutex); + if (git_mutex_init(&git__mwindow_mutex)) + return -1; /* Initialize any other subsystems that have global state */ if ((error = git_hash_global_init()) >= 0) @@ -121,7 +122,8 @@ int git_threads_init(void) if (_tls_init) return 0; - git_mutex_init(&git__mwindow_mutex); + if (git_mutex_init(&git__mwindow_mutex)) + return -1; pthread_key_create(&_tls_key, &cb__free_status); /* Initialize any other subsystems that have global state */ |