diff options
author | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2012-12-09 02:31:39 -0800 |
---|---|---|
committer | Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> | 2012-12-09 02:31:39 -0800 |
commit | a35b3864583bd1c98334aa71bb4e4c217ace55aa (patch) | |
tree | 1045996d00b52649b70e929d09114aa606e78842 /src/cache.c | |
parent | c3320aca7640386a2cfc0c785560ff4d36851ef9 (diff) | |
download | libgit2-a35b3864583bd1c98334aa71bb4e4c217ace55aa.tar.gz |
Always check the result of git_mutex_lock
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cache.c b/src/cache.c index edd3a47dd..67801758d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -52,7 +52,11 @@ void *git_cache_get(git_cache *cache, const git_oid *oid) memcpy(&hash, oid->id, sizeof(hash)); - git_mutex_lock(&cache->lock); + if (git_mutex_lock(&cache->lock)) { + giterr_set(GITERR_THREAD, "unable to lock cache mutex"); + return NULL; + } + { node = cache->nodes[hash & cache->size_mask]; @@ -73,12 +77,16 @@ void *git_cache_try_store(git_cache *cache, void *_entry) memcpy(&hash, &entry->oid, sizeof(uint32_t)); - /* increase the refcount on this object, because - * the cache now owns it */ - git_cached_obj_incref(entry); + if (git_mutex_lock(&cache->lock)) { + giterr_set(GITERR_THREAD, "unable to lock cache mutex"); + return NULL; + } - git_mutex_lock(&cache->lock); { + /* increase the refcount on this object, because + * the cache now owns it */ + git_cached_obj_incref(entry); + git_cached_obj *node = cache->nodes[hash & cache->size_mask]; if (node == NULL) { |