diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2024-02-28 10:44:07 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-28 18:47:03 +0100 |
commit | e67431d4965d13b185db3ddb4445c3c7034ca62d (patch) | |
tree | 7848fce72ce93afe70eddfb562753891b2164125 /commit-reach.c | |
parent | Git 2.44-rc2 (diff) | |
download | git-e67431d4965d13b185db3ddb4445c3c7034ca62d.tar.xz git-e67431d4965d13b185db3ddb4445c3c7034ca62d.zip |
commit-reach(paint_down_to_common): plug two memory leaks
When a commit is missing, we return early (currently pretending that no
merge basis could be found in that case). At that stage, it is possible
that a merge base could have been found already, and added to the
`result`, which is now leaked.
The priority queue has a similar issue: There might still be a commit in
that queue.
Let's release both, to address the potential memory leaks.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-reach.c')
-rw-r--r-- | commit-reach.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/commit-reach.c b/commit-reach.c index ecc913fc99..bfa1b6454d 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -104,8 +104,11 @@ static struct commit_list *paint_down_to_common(struct repository *r, parents = parents->next; if ((p->object.flags & flags) == flags) continue; - if (repo_parse_commit(r, p)) + if (repo_parse_commit(r, p)) { + clear_prio_queue(&queue); + free_commit_list(result); return NULL; + } p->object.flags |= flags; prio_queue_put(&queue, p); } |