diff options
author | Koichi Sasada <ko1@atdot.net> | 2020-10-23 13:27:21 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2020-10-29 23:42:55 +0900 |
commit | 07c03bc30984a496558d9e830bc4fb2f8cfb1854 (patch) | |
tree | 961a2eaa656943974221bbdf8cae28a9116e5f37 /proc.c | |
parent | bf951c763d00a4aee8f8c896d1a97c387fa8f30e (diff) |
check isolated Proc more strictly
Isolated Proc prohibit to access outer local variables, but it was
violated by binding and so on, so they should be error.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3721
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -424,7 +424,11 @@ get_local_variable_ptr(const rb_env_t **envp, ID lid) const rb_env_t *env = *envp; do { if (!VM_ENV_FLAGS(env->ep, VM_FRAME_FLAG_CFRAME)) { - const rb_iseq_t *iseq = env->iseq; + if (VM_ENV_FLAGS(env->ep, VM_ENV_FLAG_ISOLATED)) { + return NULL; + } + + const rb_iseq_t *iseq = env->iseq; unsigned int i; VM_ASSERT(rb_obj_is_iseq((VALUE)iseq)); @@ -3245,6 +3249,8 @@ proc_binding(VALUE self) GetProcPtr(self, proc); block = &proc->block; + if (proc->is_isolated) rb_raise(rb_eArgError, "Can't create Binding from isolated Proc"); + again: switch (vm_block_type(block)) { case block_type_iseq: @@ -4065,6 +4071,7 @@ Init_Proc(void) rb_define_method(rb_cProc, "source_location", rb_proc_location, 0); rb_define_method(rb_cProc, "parameters", rb_proc_parameters, 0); rb_define_method(rb_cProc, "ruby2_keywords", proc_ruby2_keywords, 0); + // rb_define_method(rb_cProc, "isolate", rb_proc_isolate, 0); is not accepted. /* Exceptions */ rb_eLocalJumpError = rb_define_class("LocalJumpError", rb_eStandardError); |