mirror of
https://github.com/git/git.git
synced 2026-02-28 10:47:33 +00:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
67ad42147a
commit
7451864bfa
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user