From f331b5584edbf106ab85f4663ddbe55031176b3a Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Sep 2009 08:12:12 +0000 Subject: * proc.c (proc_binding): allow proc from method. [ruby-core:25589] * vm.c (collect_local_variables_in_env): block iseq can be NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 4254fd94bb..5866f63a1d 100644 --- a/vm.c +++ b/vm.c @@ -381,19 +381,26 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp, } static int -collect_local_variables_in_env(rb_env_t * const env, const VALUE ary) +collect_local_variables_in_iseq(rb_iseq_t *iseq, const VALUE ary) { int i; - for (i = 0; i < env->block.iseq->local_table_size; i++) { - ID lid = env->block.iseq->local_table[i]; + if (!iseq) return 0; + for (i = 0; i < iseq->local_table_size; i++) { + ID lid = iseq->local_table[i]; if (rb_is_local_id(lid)) { rb_ary_push(ary, ID2SYM(lid)); } } - if (env->prev_envval) { - rb_env_t *prevenv; - GetEnvPtr(env->prev_envval, prevenv); - collect_local_variables_in_env(prevenv, ary); + return 1; +} + +static int +collect_local_variables_in_env(rb_env_t * env, const VALUE ary) +{ + + while (collect_local_variables_in_iseq(env->block.iseq, ary), + env->prev_envval) { + GetEnvPtr(env->prev_envval, env); } return 0; } -- cgit v1.2.3