mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 06:25:31 +02:00
defined zsuper: Handle NULL superclass for BasicObject
Prior to this commit, a segmentation fault occurred in `vm_defined`'s `zsuper` implementation after NULL is returned as `BasicObject`'s superclass. This fix returns false from `vm_defined` if the superclass is NULL. For example, the following code resulted in a segfault. ```ruby class BasicObject def seg_fault defined?(super) end end seg_fault ```
This commit is contained in:
parent
ffce3117b6
commit
1883dc5bde
1 changed files with 2 additions and 0 deletions
|
@ -5051,6 +5051,8 @@ vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_
|
|||
|
||||
if (me) {
|
||||
VALUE klass = vm_search_normal_superclass(me->defined_class);
|
||||
if (klass == (VALUE)NULL) return false;
|
||||
|
||||
ID id = me->def->original_id;
|
||||
|
||||
return rb_method_boundp(klass, id, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue