diff options
author | René Scharfe <l.s.r@web.de> | 2021-11-16 00:19:38 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-11-18 12:42:06 -0800 |
commit | 42c456ff8116fb0373c5cf6df54d34cb343b058e (patch) | |
tree | 2ff1840c666728ead461b2f249a8ca98fb954962 /mergesort.c | |
parent | test-mergesort: use repeatable random numbers (diff) | |
download | tgif-42c456ff8116fb0373c5cf6df54d34cb343b058e.tar.xz |
mergesort: avoid left shift overflow
Use size_t to match n when building the bitmask for checking whether a
rank is occupied, instead of the default signed int.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'mergesort.c')
-rw-r--r-- | mergesort.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mergesort.c b/mergesort.c index 6216835566..bd9c6ef8ee 100644 --- a/mergesort.c +++ b/mergesort.c @@ -63,7 +63,7 @@ void *llist_mergesort(void *list, void *next = get_next_fn(list); if (next) set_next_fn(list, NULL); - for (i = 0; n & (1 << i); i++) + for (i = 0; n & ((size_t)1 << i); i++) list = llist_merge(ranks[i], list, get_next_fn, set_next_fn, compare_fn); n++; |