threads / patch / 56577

patchpackfile: release bad_objects in close_pack()

Subject: [PATCH] packfile: release bad_objects in close_pack()

## tl;dr

2 messages between Sep 24, 2021 and Sep 24, 2021. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

René Scharfe· Sep 24, 2021, 06:10 UTC · lore

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.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 packfile.c | 1 +
 1 file changed, 1 insertion(+)
Show changes to packfile.c +1 −1
diff --git a/packfile.c b/packfile.c
index 0e92bd7bd2..89402cfc69 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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
Jeff King· Sep 24, 2021, 20:21 UTC · re: René Scharfe · lore

Re: [PATCH] packfile: release bad_objects in close_pack()

On Fri, Sep 24, 2021 at 08:10:10AM +0200, René Scharfe wrote:
Show 5 quoted lines
> 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.

Show 10 quoted lines
> diff --git a/packfile.c b/packfile.c
> index 0e92bd7bd2..89402cfc69 100644
> --- a/packfile.c
> +++ b/packfile.c
> @@ -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

← back to recent threads