Skip to content

Commit

Permalink
sha1_file: fix delta_stack memory leak in unpack_entry
Browse files Browse the repository at this point in the history
This delta_stack array can grow to any length depending on the actual
delta chain, but we forget to free it. Normally it does not matter
because we use small_delta_stack[] from stack and small_delta_stack
can hold 64-delta chains, more than standard --depth=50 in pack-objects.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Feb 24, 2014
1 parent abe601b commit 019d1e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,10 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
*final_size = size;

unuse_pack(&w_curs);

if (delta_stack != small_delta_stack)
free(delta_stack);

return data;
}

Expand Down

0 comments on commit 019d1e6

Please sign in to comment.