aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorSahitya Chandra <sahityajb@gmail.com>2026-02-21 16:08:59 +0530
committerJunio C Hamano <gitster@pobox.com>2026-02-21 21:26:53 -0800
commit7451864bfac0fc7ac829aceecd7f339b80dac732 (patch)
tree3309158fb945ac791c88185727784f284c41d0ce /builtin
parent67ad42147a7acc2af6074753ebd03d904476118f (diff)
downloadgit-7451864bfac0fc7ac829aceecd7f339b80dac732.tar.xz
pack-redundant: fix memory leak when open_pack_index() fails
In add_pack(), we allocate l.remaining_objects with llist_init() before calling open_pack_index(). If open_pack_index() fails we return NULL without freeing the allocated list, leaking the memory. Fix by calling llist_free(l.remaining_objects) on the error path before returning. Signed-off-by: Sahitya Chandra <sahityajb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/pack-redundant.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index e4ecf774ca..86749bb7e7 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -546,8 +546,10 @@ static struct pack_list * add_pack(struct packed_git *p)
l.pack = p;
llist_init(&l.remaining_objects);
- if (open_pack_index(p))
+ if (open_pack_index(p)) {
+ llist_free(l.remaining_objects);
return NULL;
+ }
base = p->index_data;
base += 256 * 4 + ((p->index_version < 2) ? 4 : 8);