Skip to content

Commit 685f225

Browse files
committed
pack: fix looping over cache entries
Fixes a regression from libgit2#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.
1 parent b13f0da commit 685f225

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
128128
/* Run with the cache lock held */
129129
static void free_lowest_entry(git_pack_cache *cache)
130130
{
131+
git_off_t offset;
131132
git_pack_cache_entry *entry;
132-
khiter_t k;
133133

134-
git_offmap_foreach(cache->entries, k, entry, {
134+
git_offmap_foreach(cache->entries, offset, entry, {
135135
if (entry && entry->refcount.val == 0) {
136136
cache->memory_used -= entry->raw.len;
137-
git_offmap_delete_at(cache->entries, k);
137+
git_offmap_delete(cache->entries, offset);
138138
free_cache_object(entry);
139139
}
140140
});

0 commit comments

Comments
 (0)