summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-03-12 16:53:37 +0900
committernagachika <nagachika@ruby-lang.org>2022-03-12 16:53:37 +0900
commite18e6af604786be481115c7340c1450332615b57 (patch)
tree6d5f0645c3338dff5502baa928d9e622766b72ae /error.c
parentbac99c5175bf58815846f9987093a6d944d07fd3 (diff)
merge revision(s) 9e0a91d0640600f2dfd7fc1d5fae6667019c9ca5: [Backport #18458]
Don't segfault if Warning.warn is undefined Check that there is a method entry for the method before passing it to rb_method_entry_arity. Fixes [Bug #18458] --- error.c | 3 ++- test/ruby/test_exception.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
Diffstat (limited to 'error.c')
-rw-r--r--error.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/error.c b/error.c
index 73705b0b58..d614a9c0a2 100644
--- a/error.c
+++ b/error.c
@@ -306,7 +306,8 @@ rb_warning_warn(VALUE mod, VALUE str)
static int
rb_warning_warn_arity(void)
{
- return rb_method_entry_arity(rb_method_entry(rb_singleton_class(rb_mWarning), id_warn));
+ const rb_method_entry_t *me = rb_method_entry(rb_singleton_class(rb_mWarning), id_warn);
+ return me ? rb_method_entry_arity(me) : 1;
}
static VALUE