summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c5
-rw-r--r--mg.c2
-rw-r--r--t/op/attrs.t4
3 files changed, 10 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 3a81248392..3ff7e7f2fa 100644
--- a/gv.c
+++ b/gv.c
@@ -1259,9 +1259,12 @@ CV*
Perl_gv_handler(pTHX_ HV *stash, I32 id)
{
dTHR;
- MAGIC *mg = mg_find((SV*)stash,'c');
+ MAGIC *mg;
AMT *amtp;
+ if (!stash)
+ return Nullcv;
+ mg = mg_find((SV*)stash,'c');
if (!mg) {
do_update:
Gv_AMupdate(stash);
diff --git a/mg.c b/mg.c
index 0ac07420f4..821c32537d 100644
--- a/mg.c
+++ b/mg.c
@@ -261,6 +261,8 @@ MAGIC*
Perl_mg_find(pTHX_ SV *sv, int type)
{
MAGIC* mg;
+ if (!sv)
+ return 0;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
if (mg->mg_type == type)
return mg;
diff --git a/t/op/attrs.t b/t/op/attrs.t
index 2702004881..f9212e4c26 100644
--- a/t/op/attrs.t
+++ b/t/op/attrs.t
@@ -142,6 +142,10 @@ eval 'my A $x : plugh plover;';
mytest qr/^SCALAR package attributes may clash with future reserved words: ["']?plugh["']? /;
BEGIN {++$ntests}
+eval 'package Cat; my Cat @socks;';
+mytest qr/^Can't declare class for non-scalar \@socks in "my"/;
+BEGIN {++$ntests}
+
sub X::MODIFY_CODE_ATTRIBUTES { die "$_[0]" }
sub X::foo { 1 }
*Y::bar = \&X::foo;