summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-01-04 09:13:19 -0800
committerJeremy Evans <code@jeremyevans.net>2022-01-04 10:03:18 -0800
commit9e0a91d0640600f2dfd7fc1d5fae6667019c9ca5 (patch)
treefb855c6b00e7bcf60f2f4d28342ad776c2fcbc01 /error.c
parente7806049c06f8e5a122d48b5454796c6ae6acac1 (diff)
downloadruby-9e0a91d0640600f2dfd7fc1d5fae6667019c9ca5.tar.gz
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]
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 6a60919d5c..c7c5159927 100644
--- a/error.c
+++ b/error.c
@@ -317,7 +317,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