aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-05-31 17:34:58 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-03 16:13:47 +0900
commitde5e0f7c0671323820c4eb9b5a11c90a26c3dad5 (patch)
tree1d505954125720f74f9fc1d541f9d427b52f5dea /vm_insnhelper.c
parentb61e82eac9fb5ac247b204dd4fbf09ac49fce530 (diff)
downloadruby-de5e0f7c0671323820c4eb9b5a11c90a26c3dad5.tar.gz
vm_invoke_proc_block: reduce recursion
According to nobu recursion can be longer than my expectation. Limit them here.
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index bd6b0a2c01..6c82d74020 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3517,11 +3517,15 @@ vm_proc_to_block_handler(VALUE procval)
static VALUE
vm_invoke_proc_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
struct rb_calling_info *calling, const struct rb_callinfo *ci,
- MAYBE_UNUSED(bool is_lambda), VALUE block_handler)
+ bool is_lambda, VALUE block_handler)
{
- return vm_invoke_block(ec, reg_cfp, calling, ci,
- block_proc_is_lambda(VM_BH_TO_PROC(block_handler)),
- vm_proc_to_block_handler(VM_BH_TO_PROC(block_handler)));
+ while (vm_block_handler_type(block_handler) == block_handler_type_proc) {
+ VALUE proc = VM_BH_TO_PROC(block_handler);
+ is_lambda = block_proc_is_lambda(proc);
+ block_handler = vm_proc_to_block_handler(proc);
+ }
+
+ return vm_invoke_block(ec, reg_cfp, calling, ci, is_lambda, block_handler);
}
static inline VALUE