Skip to content

Commit beccbdd

Browse files
brandb97gitster
authored andcommitted
commit-graph: fix memory leak when fill_oids_from_packs() fails
In commit-graph.c:fill_oids_from_packs, if open_pack_index failed, memory allocated and returned by add_packed_git will leak. Simply add close_pack and free(p) will solve this problem. Signed-off-by: Lidong Yan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1a8a497 commit beccbdd

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
@@ -1929,6 +1929,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
19291929
}
19301930
if (open_pack_index(p)) {
19311931
ret = error(_("error opening index for %s"), packname.buf);
1932+
close_pack(p);
1933+
free(p);
19321934
goto cleanup;
19331935
}
19341936
for_each_object_in_pack(p, add_packed_commits, ctx,

0 commit comments

Comments
 (0)