1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix crash when clearing method cache for builtin method

Builtin methods do not always have their mandatory_only_cme created (it
is only created when called with only mandatory parameters), so it could
be null. If we try to clear the cme, it will crash because it is null.

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
This commit is contained in:
Peter Zhu 2021-11-16 15:01:05 -05:00
parent b95d7d2099
commit c400165afa
Notes: git 2021-11-17 23:03:27 +09:00

View file

@ -209,7 +209,7 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
vm_cme_invalidate((rb_callable_method_entry_t *)cme);
RB_DEBUG_COUNTER_INC(cc_invalidate_tree_cme);
if (cme->def->iseq_overload) {
if (cme->def->iseq_overload && cme->def->body.iseq.mandatory_only_cme) {
vm_cme_invalidate((rb_callable_method_entry_t *)cme->def->body.iseq.mandatory_only_cme);
}
}