]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph: fix memory leak when `fill_oids_from_packs()` fails
authorLidong Yan <502024330056@smail.nju.edu.cn>
Fri, 9 May 2025 08:30:35 +0000 (08:30 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 May 2025 21:32:40 +0000 (14:32 -0700)
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>
commit-graph.c

index 6394752b0b0868b4337cf36f5747c2a9b36c364c..93d867770b05d28b8f5e67ca2b069ba87daf2824 100644 (file)
@@ -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,