Skip to content

Commit 1d94abf

Browse files
peffgitster
authored andcommitted
commit-graph: free graph struct that was not added to chain
When reading the graph chain file, we open (and allocate) each individual slice it mentions and then add them to a linked-list chain. But if adding to the chain fails (e.g., because the base-graph chunk it contains didn't match what we expected), we leave the function without freeing the graph struct that caused the failure, leaking it. We can fix it by calling free_graph_commit(). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 991d549 commit 1d94abf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

commit-graph.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r,
566566
if (add_graph_to_chain(g, graph_chain, oids, i)) {
567567
graph_chain = g;
568568
valid = 1;
569+
} else {
570+
free_commit_graph(g);
569571
}
570572

571573
break;

0 commit comments

Comments
 (0)