diff --git a/ChangeLog b/ChangeLog index bd6b1e982c..96d271efb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jul 14 14:04:06 2007 Nobuyoshi Nakada + + * enum.c (sort_by_cmp): check if reentered. [ruby-dev:24291] + Sat Jul 14 11:08:28 2007 Yukihiro Matsumoto * ext/json/ext/generator/generator.c (check_max_nesting): wrong diff --git a/enum.c b/enum.c index 1cde4145ff..a93b171c08 100644 --- a/enum.c +++ b/enum.c @@ -627,7 +627,11 @@ sort_by_cmp(const void *ap, const void *bp, void *data) { VALUE a = (*(NODE *const *)ap)->u1.value; VALUE b = (*(NODE *const *)bp)->u1.value; + VALUE ary = (VALUE)data; + if (RBASIC(ary)->klass) { + rb_raise(rb_eRuntimeError, "sort_by reentered"); + } return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b); } @@ -717,7 +721,8 @@ enum_sort_by(VALUE obj) RBASIC(ary)->klass = 0; rb_block_call(obj, id_each, 0, 0, sort_by_i, ary); if (RARRAY_LEN(ary) > 1) { - ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE), sort_by_cmp, 0); + ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE), + sort_by_cmp, (void *)ary); } if (RBASIC(ary)->klass) { rb_raise(rb_eRuntimeError, "sort_by reentered");