@matheusbsbs / matheus-bagliano / commits / 6fc74703de
Fork 0

pack-objects: Fix segfault when object count is less than thread count

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>

Nicolas Pitre committed Jan 21, 2008 at 11:07 UTC 6fc74703dee571859d8be270f5496f4c9b2ff9c7
1 file changed +2 -1
builtin-pack-objects.c
+2 -1
@@ -1672,7 +1672,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
1672 p[i].data_ready = 0;
1673
1674 /* try to split chunks on "path" boundaries */
1675 - while (sub_size < list_size && list[sub_size]->hash &&
1675 + while (sub_size && sub_size < list_size &&
1676 + list[sub_size]->hash &&
1677 list[sub_size]->hash == list[sub_size-1]->hash)
1678 sub_size++;
1679