Change 33367 by [EMAIL PROTECTED] on 2008/02/25 10:54:47
Avoid a segfault case in MRO code, based on :
Subject: [perl #51092] [PATCH] Segfault when calling ->next::method on
non-existing package
From: [EMAIL PROTECTED] (via RT) <[EMAIL PROTECTED]>
Date: Thu, 21 Feb 2008 20:29:42 -0800
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/perl/mro.c#46 edit
... //depot/perl/t/mro/next_edgecases.t#2 edit
Differences ...
==== //depot/perl/mro.c#46 (text) ====
Index: perl/mro.c
--- perl/mro.c#45~33291~ 2008-02-12 05:15:20.000000000 -0800
+++ perl/mro.c 2008-02-25 02:54:47.000000000 -0800
@@ -954,7 +954,7 @@
if(sv_isobject(self))
selfstash = SvSTASH(SvRV(self));
else
- selfstash = gv_stashsv(self, 0);
+ selfstash = gv_stashsv(self, GV_ADD);
assert(selfstash);
==== //depot/perl/t/mro/next_edgecases.t#2 (text) ====
Index: perl/t/mro/next_edgecases.t
--- perl/t/mro/next_edgecases.t#1~30998~ 2007-04-20 08:38:47.000000000
-0700
+++ perl/t/mro/next_edgecases.t 2008-02-25 02:54:47.000000000 -0800
@@ -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 @@
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");
+
}
End of Patch.