Skip to content

Commit

Permalink
proc.c: fix infinite loop
Browse files Browse the repository at this point in the history
* proc.c (bind_local_variables): update env from envval for each
  iterations.  [ruby-dev:48351] [Bug #10001]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jul 1, 2014
1 parent bc1fafa commit 02c391a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Wed Jul 2 02:14:37 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* proc.c (bind_local_variables): update env from envval for each
iterations. [ruby-dev:48351] [Bug #10001]

Tue Jul 1 23:46:34 2014 NAKAMURA Usaku <usa@ruby-lang.org>

* NEWS: [DOC] mention about Binding#local_variables, introduced at
Expand Down
3 changes: 2 additions & 1 deletion proc.c
Expand Up @@ -476,12 +476,13 @@ bind_local_variables(VALUE bindval)
GetBindingPtr(bindval, bind);

envval = bind->env;
GetEnvPtr(envval, env);

do {
const rb_iseq_t *iseq;
int i;
ID id;

GetEnvPtr(envval, env);
iseq = env->block.iseq;

for (i = 0; i < iseq->local_table_size; i++) {
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_proc.rb
Expand Up @@ -1256,6 +1256,11 @@ def test_local_variables
assert_equal(%i[if case when begin end a], b.local_variables)
end

def test_local_variables_nested
b = tap {break binding}
assert_equal(%i[b], b.local_variables, '[ruby-dev:48351] [Bug #10001]')
end

def local_variables_of(bind)
this_should_not_be_in_bind = 2
bind.local_variables
Expand Down

0 comments on commit 02c391a

Please sign in to comment.