From 3f8f46260df6761c2dfca5c829d94c03c274d7d7 Mon Sep 17 00:00:00 2001 From: Daniel Chetlin Date: Sat, 23 Dec 2000 20:09:49 -0800 Subject: [PATCH] Re: [PATCH blead] Fix segfault in gv_handler/mg_find Message-ID: <20001224040949.B3090@darkstar> p4raw-id: //depot/perl@8236 --- gv.c | 5 ++++- mg.c | 2 ++ t/op/attrs.t | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gv.c b/gv.c index 3a81248..3ff7e7f 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 0ac0742..821c325 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 2702004..f9212e4 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; -- 2.7.4