Skip to contentSkip to conversation

packfile: release bad_objects in close_pack()

PATCH In review René Scharfe 2 participants 2 messages Sep 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 packfile: release bad_objects in close_pack()

Unusable entries of a damaged pack file are recorded in the oidset bad_objects. Release it when we're done with the pack.

This doesn't affect intact packs because an empty oidset requires no allocation.

---
 packfile.c | 1 +
 1 file changed, 1 insertion(+)
packfile.c +1 -0
index 0e92bd7bd2..89402cfc69 100644
@@ -339,6 +339,7 @@ void close_pack(struct packed_git *p)
 	close_pack_fd(p);
 	close_pack_index(p);
 	close_pack_revindex(p);
+	oidset_clear(&p->bad_objects);
 }
 
 void close_object_store(struct raw_object_store *o)

--
2.33.0

#1 lore raw
Quoted 5 lines · René Scharfe

Unusable entries of a damaged pack file are recorded in the oidset bad_objects. Release it when we're done with the pack.

This doesn't affect intact packs because an empty oidset requires no allocation.

Good catch. I wondered if this was related to your recent 09ef66179b (packfile: use oidset for bad objects, 2021-09-11), but we'd have just leaked the manual array before then.

packfile.c void close_pack(struct packed_git *p) · line 343

Quoted 10 lines
packfile.c +1 -0
index 0e92bd7bd2..89402cfc69 100644
@@ -339,6 +339,7 @@ void close_pack(struct packed_git *p)
 	close_pack_fd(p);
 	close_pack_index(p);
 	close_pack_revindex(p);
+	oidset_clear(&p->bad_objects);
 }

Looks obviously correct.

-Peff