1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2013-12-14 02:45:07 +00:00
parent 241ca7bfff
commit fcd7887407
2 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Sat Dec 14 11:44:52 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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]
Sat Dec 14 11:25:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (rb_mod_const_defined): support nested class path as

4
util.c
View file

@ -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;