diff options
author | Vicent Martà <vicent@github.com> | 2012-09-11 11:04:09 -0700 |
---|---|---|
committer | Vicent Martà <vicent@github.com> | 2012-09-11 11:04:09 -0700 |
commit | 5a409c44baf2c7c2bd36fb8e8c2d5b2ce5b1908b (patch) | |
tree | 163e4ce1ceea09ef45fcc3b18b3e139016ab621c | |
parent | 2130dee49ffee6c55b49f4f5cd447b2fb7e0acc3 (diff) | |
parent | 6ee6861123ccb599af584377dd8b75eeea24858b (diff) | |
download | libgit2-5a409c44baf2c7c2bd36fb8e8c2d5b2ce5b1908b.tar.gz |
Merge pull request #924 from schu/cache-fix-race-cond
cache: fix race condition
-rw-r--r-- | src/cache.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cache.c b/src/cache.c index 3aa14f012..1f5b8872c 100644 --- a/src/cache.c +++ b/src/cache.c @@ -89,12 +89,13 @@ void *git_cache_try_store(git_cache *cache, void *_entry) git_cached_obj_decref(node, cache->free_obj); cache->nodes[hash & cache->size_mask] = entry; } + + /* increase the refcount again, because we are + * returning it to the user */ + git_cached_obj_incref(entry); + } git_mutex_unlock(&cache->lock); - /* increase the refcount again, because we are - * returning it to the user */ - git_cached_obj_incref(entry); - return entry; } |