Skip to content

Commit ee63d02

Browse files
dschogitster
authored andcommitted
commit-graph: avoid using stale stack addresses
The code is a bit too hard to reason about to fully assess whether the `fill_commit_graph_info()` function is called at all after `write_commit_graph()` returns (and hence the stack variable `topo_levels` goes out of context). Let's simply make sure that the stack address is no longer used at that stage, thereby making the code quite a bit easier to reason about. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fc451e6 commit ee63d02

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

commit-graph.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,15 @@ int write_commit_graph(struct object_directory *odb,
26832683
oid_array_clear(&ctx.oids);
26842684
clear_topo_level_slab(&topo_levels);
26852685

2686+
if (ctx.r->objects->commit_graph) {
2687+
struct commit_graph *g = ctx.r->objects->commit_graph;
2688+
2689+
while (g) {
2690+
g->topo_levels = NULL;
2691+
g = g->base_graph;
2692+
}
2693+
}
2694+
26862695
for (i = 0; i < ctx.num_commit_graphs_before; i++)
26872696
free(ctx.commit_graph_filenames_before[i]);
26882697
free(ctx.commit_graph_filenames_before);

0 commit comments

Comments
 (0)