[前][次][番号順一覧][スレッド一覧]

ruby-changes:69782

From: Peter <ko1@a...>
Date: Wed, 17 Nov 2021 23:03:23 +0900 (JST)
Subject: [ruby-changes:69782] c400165afa (master): Fix crash when clearing method cache for builtin method

https://git.ruby-lang.org/ruby.git/commit/?id=c400165afa

From c400165afaca06dcff06d980c8f7fe46ff3904e4 Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Tue, 16 Nov 2021 15:01:05 -0500
Subject: 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@r...>
---
 vm_method.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vm_method.c b/vm_method.c
index b41b0ff9087..337d3260923 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -209,7 +209,7 @@ clear_method_cache_by_id_in_class(VALUE klass, ID mid) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L209
                 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);
                 }
             }
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]