summaryrefslogtreecommitdiff
path: root/enumerator.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-29 05:38:58 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-29 05:38:58 +0000
commit0678e0250181948c998d96219ac03eb471b53edc (patch)
treefc11af70bb26b46075c379e7350173413e553521 /enumerator.c
parentf984d0782bdd4efeea8f18eae6ba00f8a713f093 (diff)
merge revision(s) 39722,43929: [Backport #9178]
* enumerator.c (enumerator_with_index): try to convert given offset to integer. fix bug introduced in r39594. * 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_1_9_3@44745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/enumerator.c b/enumerator.c
index 451327569e..ef99bf85fa 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -13,6 +13,7 @@
************************************************/
#include "ruby/ruby.h"
+#include "node.h"
/*
* Document-class: Enumerator
@@ -368,9 +369,9 @@ enumerator_each(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);
@@ -401,7 +402,7 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj)
memo = INT2FIX(0);
else
memo = rb_to_int(memo);
- 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));
}
/*