From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS24940 5.9.0.0/16 X-Spam-Status: No, score=-2.5 required=3.0 tests=AWL,BAYES_00, RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_ZBI,SPF_FAIL,SPF_HELO_FAIL, TO_EQ_FM_DOM_SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from 80x24.org (tor-relay.zwiebeltoralf.de [5.9.158.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 71A301F404 for ; Tue, 30 Jan 2018 00:46:44 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] proc: fix super_method segfault after bind Date: Tue, 30 Jan 2018 00:46:26 +0000 Message-Id: <20180130004626.17796-1-e@80x24.org> List-Id: * proc.c: handle undefined iclass [ruby-core:85231] [Bug #14421] --- proc.c | 1 + test/ruby/test_method.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/proc.c b/proc.c index 4f909dac4b..86610ddfd8 100644 --- a/proc.c +++ b/proc.c @@ -2725,6 +2725,7 @@ method_super_method(VALUE method) TypedData_Get_Struct(method, struct METHOD, &method_data_type, data); iclass = data->iclass; + if (!iclass) return Qnil; super_class = RCLASS_SUPER(RCLASS_ORIGIN(iclass)); mid = data->me->called_id; if (!super_class) return Qnil; diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index e016662375..0ef913fd78 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -926,6 +926,11 @@ def test_super_method_with_prepended_module assert_equal(m1.source_location, m2.source_location, bug) end + def test_super_method_after_bind + assert_nil String.instance_method(:length).bind(String.new).super_method, + '[ruby-core:85231] [Bug #14421]' + end + def rest_parameter(*rest) rest end -- EW