From d05f04d27dd86c67e4a8dfff4392f806cf577bdf Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 2 Jun 2020 18:55:06 +0900 Subject: Fixed `defined?` against protected method call Protected methods are restricted to be called according to the class/module in where it is defined, not the actual receiver's class. [Bug #16931] --- vm_insnhelper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f6e379582e..9494b8b20c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -3603,7 +3603,7 @@ vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_ case METHOD_VISI_PRIVATE: break; case METHOD_VISI_PROTECTED: - if (!rb_obj_is_kind_of(GET_SELF(), rb_class_real(klass))) { + if (!rb_obj_is_kind_of(GET_SELF(), rb_class_real(me->defined_class))) { break; } case METHOD_VISI_PUBLIC: -- cgit v1.2.3