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
Родитель b95d7d2099
Коммит c400165afa
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -209,7 +209,7 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid)
vm_cme_invalidate((rb_callable_method_entry_t *)cme); vm_cme_invalidate((rb_callable_method_entry_t *)cme);
RB_DEBUG_COUNTER_INC(cc_invalidate_tree_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); vm_cme_invalidate((rb_callable_method_entry_t *)cme->def->body.iseq.mandatory_only_cme);
} }
} }