summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:48:50 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:48:50 +0000
commitc27bd84806454f4627d8957a87b6186da1aab089 (patch)
treead209293976fac561c18e38dfc2a0a90e68465a5 /enumerator.c
parentb851418bb7bfa498566c548bd5ea535cc13aa2eb (diff)
merge revision(s) 43929: [Backport #9178]
* enumerator.c (enumerator_with_index): should not store local variable address to memoise the arguments. it is invalidated after the return. [ruby-core:58692] [Bug #9178] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/enumerator.c b/enumerator.c
index dc8c9d3504..e20a612358 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -460,9 +460,9 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
static VALUE
enumerator_with_index_i(VALUE val, VALUE m, int argc, VALUE *argv)
{
- VALUE *memo = (VALUE *)m;
- VALUE idx = *memo;
- *memo = rb_int_succ(idx);
+ NODE *memo = (NODE *)m;
+ VALUE idx = memo->u1.value;
+ memo->u1.value = rb_int_succ(idx);
if (argc <= 1)
return rb_yield_values(2, val, idx);
@@ -494,7 +494,7 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj)
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_size);
if (NIL_P(memo))
memo = INT2NUM(0);
- return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)&memo);
+ return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)NEW_MEMO(memo, 0, 0));
}
/*