summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorLidong Yan <502024330056@smail.nju.edu.cn>2025-05-09 08:30:35 +0000
committerJunio C Hamano <gitster@pobox.com>2025-05-15 14:32:40 -0700
commitbeccbddb6802c0b56e34bb1d55cecceb093940f4 (patch)
tree69308d66315a12d4e3e1d141b955653764aa0fd3 /commit-graph.c
parent1a8a4971cc6c179c4dd711f4a7f5d7178f4b3ab7 (diff)
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 <502024330056@smail.nju.edu.cn> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 6394752b0b..93d867770b 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1929,6 +1929,8 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
}
if (open_pack_index(p)) {
ret = error(_("error opening index for %s"), packname.buf);
+ close_pack(p);
+ free(p);
goto cleanup;
}
for_each_object_in_pack(p, add_packed_commits, ctx,