Skip to content

Commit ff5eea0

Browse files
committed
pack: dereference cached pack entry on error
When trying to uncompress deltas in a packfile's delta chain, we try to add object bases to the packfile cache, subsequently decrementing its reference count if it has been added successfully. This may lead to a mismatched reference count in the case where we exit the loop early due to an encountered error. Fix the issue by decrementing the reference count in error cleanup.
1 parent 8339c66 commit ff5eea0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/pack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,11 @@ int git_packfile_unpack(
757757
}
758758

759759
cleanup:
760-
if (error < 0)
760+
if (error < 0) {
761761
git__free(obj->data);
762+
if (cached)
763+
git_atomic_dec(&cached->refcount);
764+
}
762765

763766
if (elem)
764767
*obj_offset = curpos;

0 commit comments

Comments
 (0)