From: ilmari@vesla.ilmari.org Date: Thu, 21 Feb 2008 20:29:42 +0000 (-0800) Subject: Avoid a segfault case in MRO code, based on : X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5fa9f95182cd3e9dfed1f750408ef8b876d6a9c6;p=p5sagit%2Fp5-mst-13.2.git Avoid a segfault case in MRO code, based on : Subject: [perl #51092] [PATCH] Segfault when calling ->next::method on non-existing package From: ilmari@vesla.ilmari.org (via RT) Message-ID: p4raw-id: //depot/perl@33367 --- diff --git a/mro.c b/mro.c index 83872dc..2d52805 100644 --- a/mro.c +++ b/mro.c @@ -954,7 +954,7 @@ XS(XS_mro_nextcan) if(sv_isobject(self)) selfstash = SvSTASH(SvRV(self)); else - selfstash = gv_stashsv(self, 0); + selfstash = gv_stashsv(self, GV_ADD); assert(selfstash); diff --git a/t/mro/next_edgecases.t b/t/mro/next_edgecases.t index 91c2c85..ff3272d 100644 --- a/t/mro/next_edgecases.t +++ b/t/mro/next_edgecases.t @@ -3,7 +3,7 @@ use strict; use warnings; -require q(./test.pl); plan(tests => 11); +require q(./test.pl); plan(tests => 12); { @@ -78,5 +78,16 @@ require q(./test.pl); plan(tests => 11); eval { $baz->bar() }; ok($@, '... calling bar() with next::method failed') || diag $@; - } + } + + # Test with non-existing class (used to segfault) + { + package Qux; + use mro; + sub foo { No::Such::Class->next::can } + } + + eval { Qux->foo() }; + is($@, '', "->next::can on non-existing package name"); + }