This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Double magic with '\&$x'
authorVincent Pit <perl@profvince.com>
Tue, 1 Apr 2008 10:48:17 +0000 (12:48 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 11 Apr 2008 12:32:09 +0000 (12:32 +0000)
From: "Vincent Pit" <perl@profvince.com>
Message-ID: <34395.147.210.17.175.1207039697.squirrel@147.210.17.175>

p4raw-id: //depot/perl@33668

sv.c

diff --git a/sv.c b/sv.c
index 96ef7c8..f9546e1 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -7872,8 +7872,8 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref)
        goto fix_gv;
 
     default:
-       SvGETMAGIC(sv);
        if (SvROK(sv)) {
+           SvGETMAGIC(sv);
            SV * const *sp = &sv;       /* Used in tryAMAGICunDEREF macro. */
            tryAMAGICunDEREF(to_cv);
 
@@ -7889,10 +7889,12 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref)
            else
                Perl_croak(aTHX_ "Not a subroutine reference");
        }
-       else if (isGV(sv))
+       else if (isGV(sv)) {
+           SvGETMAGIC(sv);
            gv = (GV*)sv;
+       }
        else
-           gv = gv_fetchsv(sv, lref, SVt_PVCV);
+           gv = gv_fetchsv(sv, lref, SVt_PVCV); /* Calls get magic */
        *gvp = gv;
        if (!gv) {
            *st = NULL;