[PATCH 01/12] paint_down_to_common: plug a memory leak
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Feb 13, 2024, 08:41 UTC
- Message-ID
- <818eef0a64443e42c288ea3b294bf52e7411914b.1707813709.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.1657.git.1707813709.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
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.
Let's release it, to address that memory leak.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- commit-reach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/commit-reach.c b/commit-reach.c index a868a575ea1..b2b102926c9 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -105,8 +105,10 @@ 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)) { + free_commit_list(result); return NULL; + } p->object.flags |= flags; prio_queue_put(&queue, p); }
-- gitgitgadget