summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2021-11-16 15:01:05 -0500
committerPeter Zhu <peter@peterzhu.ca>2021-11-17 09:02:57 -0500
commitc400165afaca06dcff06d980c8f7fe46ff3904e4 (patch)
tree2e41dab8a177e7eac40070dbffb3f62ad8fc6574
parentb95d7d2099e0d9df68c08f23991ba35db6126bf5 (diff)
downloadruby-c400165afaca06dcff06d980c8f7fe46ff3904e4.tar.gz
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>
-rw-r--r--vm_method.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index b41b0ff908..337d326092 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -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);
}
}