summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2022-01-30 19:02:23 +0900
committerNARUSE, Yui <naruse@airemix.jp>2022-01-30 19:02:23 +0900
commitd3a2a3c5420fecfee54cbf3fbdd9287bc6c58f03 (patch)
tree604b98ac5078c53e1bf692534459c07135b9f891 /error.c
parent2640161df5cf18d08ec86a0c1b913d4ee99e102a (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 926ec5adb9..a870d0200b 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