summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Haslam <jason@scitools.com>2017-02-22 09:29:00 -0700
committerJason Haslam <jason@scitools.com>2017-02-22 09:29:00 -0700
commit685f22519c617e087a74b0754a10ceebc1ec9d77 (patch)
treeccf25d0fc38a7831a52680e967b062e3d6b79917
parentb13f0da153aa47fbf113c44e734be2be603870b6 (diff)
downloadlibgit2-685f22519c617e087a74b0754a10ceebc1ec9d77.tar.gz
pack: fix looping over cache entries
Fixes a regression from #4092. This is a crash on 32-bit and I assume that it doesn't do the right thing on 64-bit either. MSVC emits a warning for this, but of course, it's easy to get lost among all of the similar 'possible loss of data' warnings.
-rw-r--r--src/pack.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pack.c b/src/pack.c
index d59fae412..60b757e90 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -128,13 +128,13 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
/* Run with the cache lock held */
static void free_lowest_entry(git_pack_cache *cache)
{
+ git_off_t offset;
git_pack_cache_entry *entry;
- khiter_t k;
- git_offmap_foreach(cache->entries, k, entry, {
+ git_offmap_foreach(cache->entries, offset, entry, {
if (entry && entry->refcount.val == 0) {
cache->memory_used -= entry->raw.len;
- git_offmap_delete_at(cache->entries, k);
+ git_offmap_delete(cache->entries, offset);
free_cache_object(entry);
}
});