Skip to content

Commit e67431d

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f41f85c commit e67431d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

commit-reach.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ static struct commit_list *paint_down_to_common(struct repository *r,
104104
parents = parents->next;
105105
if ((p->object.flags & flags) == flags)
106106
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);
108110
return NULL;
111+
}
109112
p->object.flags |= flags;
110113
prio_queue_put(&queue, p);
111114
}

0 commit comments

Comments
 (0)