From: Sergey Vlasov <vsu@altlinux.ru>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Sergey Vlasov <vsu@altlinux.ru>
Subject: pack-objects: Fix segfault when object count is less than thread count
Date: Mon, 21 Jan 2008 17:35:45 +0300 [thread overview]
Message-ID: <1200926145-14625-1-git-send-email-vsu@altlinux.ru> (raw)
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]. Fix this by ensuring that sub_size
is not zero if there is at least one object to process.
Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
---
builtin-pack-objects.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ec10238..cdf8aae 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1665,6 +1665,9 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
for (i = 0; i < delta_search_threads; i++) {
unsigned sub_size = list_size / (delta_search_threads - i);
+ if (sub_size == 0 && list_size >= 1)
+ sub_size = 1;
+
p[i].window = window;
p[i].depth = depth;
p[i].processed = processed;
--
1.5.4.rc4.14.gd50a3
next reply other threads:[~2008-01-21 14:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-21 14:35 Sergey Vlasov [this message]
2008-01-21 15:12 ` pack-objects: Fix segfault when object count is less than thread count Johannes Sixt
2008-01-21 16:08 ` Nicolas Pitre
2008-01-21 16:07 ` Nicolas Pitre
2008-01-21 17:40 ` Sergey Vlasov
2008-01-21 17:53 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1200926145-14625-1-git-send-email-vsu@altlinux.ru \
--to=vsu@altlinux.ru \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox