summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-14 02:45:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-14 02:45:07 +0000
commitfcd78874078b5b09be30fe891656949b59b5163c (patch)
treedfd3080ee8a23feb102de5d4beea19a30ff4ba1f /util.c
parent241ca7bfff26b1f624ef64212b68d76efcb78f9d (diff)
util.c: bump stack size in ruby_qsort()
* util.c (ruby_qsort): fix potential stack overflow on a large machine. based on the patch by Conrad Irwin <conrad.irwin AT gmail.com> at [ruby-core:51816]. [Bug #7772] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util.c b/util.c
index f6f233b6e4..b0f9030c42 100644
--- a/util.c
+++ b/util.c
@@ -310,7 +310,9 @@ ruby_qsort(void* base, const size_t nel, const size_t size, cmpfunc_t *cmp, void
char *L = base; /* left end of current region */
char *R = (char*)base + size*(nel-1); /* right end of current region */
size_t chklim = 63; /* threshold of ordering element check */
- stack_node stack[32], *top = stack; /* 32 is enough for 32bit CPU */
+ enum {size_bits = sizeof(size) * CHAR_BIT};
+ stack_node stack[size_bits]; /* enough for size_t size */
+ stack_node *top = stack;
int mmkind;
size_t high, low, n;