Skip to content

Commit 274bfa7

Browse files
peffgitster
authored andcommitted
commit-graph: free write-context entries before overwriting
When writing a split graph file, we replace the final element of the commit_graph_hash_after and commit_graph_filenames_after arrays. But since these are allocated strings, we need to free them before overwriting to avoid leaking the old string. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d94abf commit 274bfa7

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
@@ -2065,9 +2065,11 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
20652065
free(graph_name);
20662066
}
20672067

2068+
free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
20682069
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash));
20692070
final_graph_name = get_split_graph_filename(ctx->odb,
20702071
ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]);
2072+
free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]);
20712073
ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name;
20722074

20732075
result = rename(ctx->graph_name, final_graph_name);

0 commit comments

Comments
 (0)