aboutsummaryrefslogtreecommitdiff
path: root/builtin-pack-objects.c
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2008-01-21 11:07:15 -0500
committerJunio C Hamano <gitster@pobox.com>2008-01-21 17:24:12 -0800
commit6fc74703dee571859d8be270f5496f4c9b2ff9c7 (patch)
tree892ac23f25fdef491181c55e7fa2a3a2e18b01c6 /builtin-pack-objects.c
parent9288bedafa5a61689d6bef920c707b1ff9fe080a (diff)
downloadgit-6fc74703dee571859d8be270f5496f4c9b2ff9c7.tar.gz
git-6fc74703dee571859d8be270f5496f4c9b2ff9c7.tar.xz
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>
Diffstat (limited to 'builtin-pack-objects.c')
-rw-r--r--builtin-pack-objects.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ec10238e4..d3efeff03 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -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++;