Skip to content

Commit

Permalink
pack-objects: Fix segfault when object count is less than thread count
Browse files Browse the repository at this point in the history
When partitioning the work amongst threads, dividing the number of
objects by the number of threads may return 0 when there are less
objects than threads; this will cause the subsequent code to segfault
when accessing list[sub_size-1].  Allow some threads to have
zero objects to work on instead of barfing, while letting others
to have more.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nicolas Pitre authored and gitster committed Jan 22, 2008
1 parent 9288bed commit 6fc7470
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
p[i].data_ready = 0;

/* try to split chunks on "path" boundaries */
while (sub_size < list_size && list[sub_size]->hash &&
while (sub_size && sub_size < list_size &&
list[sub_size]->hash &&
list[sub_size]->hash == list[sub_size-1]->hash)
sub_size++;

Expand Down

0 comments on commit 6fc7470

Please sign in to comment.