diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-09-30 11:14:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-09-30 20:23:07 +0200 |
commit | 6512d6e473c1c1f9f2e6967e2703a19784109a8b (patch) | |
tree | e7796fa5a8dcee970add8aab88314f6b76dfceff /revision.c | |
parent | revision: fix memory leaks when rewriting parents (diff) | |
download | git-6512d6e473c1c1f9f2e6967e2703a19784109a8b.tar.xz git-6512d6e473c1c1f9f2e6967e2703a19784109a8b.zip |
revision: fix leaking saved parents
The `saved_parents` slab is used by `--full-diff` to save parents of a
commit which we are about to rewrite. We do not release its contents
once it's not used anymore, causing a memory leak. Plug it.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/revision.c b/revision.c index 6b452ea182..f5f5b84f2b 100644 --- a/revision.c +++ b/revision.c @@ -4207,10 +4207,18 @@ static void save_parents(struct rev_info *revs, struct commit *commit) *pp = EMPTY_PARENT_LIST; } +static void free_saved_parent(struct commit_list **parents) +{ + if (*parents != EMPTY_PARENT_LIST) + free_commit_list(*parents); +} + static void free_saved_parents(struct rev_info *revs) { - if (revs->saved_parents_slab) - clear_saved_parents(revs->saved_parents_slab); + if (!revs->saved_parents_slab) + return; + deep_clear_saved_parents(revs->saved_parents_slab, free_saved_parent); + FREE_AND_NULL(revs->saved_parents_slab); } struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit) |