summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-20 12:47:20 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-20 12:47:20 +0000
commit2ec51ee0d506c90f3afba694e6c502ef3d52e4f8 (patch)
treedb3928abc44090d749b6609bfb7ef49f2631a5c9 /enum.c
parent959077c8e0ec27dfa72025a85c99a4acc26f6491 (diff)
* string.c (str_gsub): reentrant check. [ruby-dev:24432]
* backport all SEGV bug fixes from CVS HEAD. [ruby-dev:24536] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/enum.c b/enum.c
index 9bf68f7e9c..2f931c7d8b 100644
--- a/enum.c
+++ b/enum.c
@@ -389,6 +389,9 @@ sort_by_i(i, ary)
NODE *memo;
v = rb_yield(i);
+ if (RBASIC(ary)->klass) {
+ rb_raise(rb_eRuntimeError, "sort_by reentered");
+ }
memo = rb_node_newnode(NODE_MEMO, v, i, 0);
rb_ary_push(ary, (VALUE)memo);
return Qnil;
@@ -486,6 +489,7 @@ enum_sort_by(obj)
else {
ary = rb_ary_new();
}
+ RBASIC(ary)->klass = 0;
rb_iterate(rb_each, obj, sort_by_i, ary);
if (RARRAY(ary)->len > 1) {
qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
@@ -493,6 +497,7 @@ enum_sort_by(obj)
for (i=0; i<RARRAY(ary)->len; i++) {
RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
}
+ RBASIC(ary)->klass = rb_cArray;
return ary;
}
@@ -879,7 +884,7 @@ enum_zip(argc, argv, obj)
NODE *memo;
for (i=0; i<argc; i++) {
- argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_ary");
+ argv[i] = rb_convert_type(argv[i], T_ARRAY, "Array", "to_a");
}
result = rb_block_given_p() ? Qnil : rb_ary_new();
memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), 0);