From: Daniel Chetlin Date: Sun, 24 Dec 2000 04:09:49 +0000 (-0800) Subject: Re: [PATCH blead] Fix segfault in gv_handler/mg_find X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3f8f46260df6761c2dfca5c829d94c03c274d7d7;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH blead] Fix segfault in gv_handler/mg_find Message-ID: <20001224040949.B3090@darkstar> p4raw-id: //depot/perl@8236 --- 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;