From a35b3864583bd1c98334aa71bb4e4c217ace55aa Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Sun, 9 Dec 2012 02:31:39 -0800 Subject: Always check the result of git_mutex_lock --- src/cache.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/cache.c') 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) { -- cgit v1.2.1