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>
Johannes Schindelin committed
Feb 28, 2024 at 09:44 UTC
e67431d4965d13b185db3ddb4445c3c7034ca62d
1 file changed
+4
-1
commit-reach.c
+4
-1
@@ -104,8 +104,11 @@ static struct commit_list *paint_down_to_common(struct repository *r,
104
parents = parents->next;
105
if ((p->object.flags & flags) == flags)
106
continue;
107
- if (repo_parse_commit(r, p))
107
+ if (repo_parse_commit(r, p)) {
108
+ clear_prio_queue(&queue);
109
+ free_commit_list(result);
110
return NULL;
111
+ }
112
p->object.flags |= flags;
113
prio_queue_put(&queue, p);
114
}