summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9288bed)
raw | patch | inline | side by side (parent: 9288bed)
author | Nicolas Pitre <nico@cam.org> | |
Mon, 21 Jan 2008 16:07:15 +0000 (11:07 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 22 Jan 2008 01:24:12 +0000 (17:24 -0800) |
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>
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>
builtin-pack-objects.c | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ec10238e4a0d81773820d255ed0861dd66e0c3d6..d3efeff03f89cc0f4d0da463ddf878c28effb31e 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
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++;