This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_leavesublv(): croak on *all* PADTMPs
[perl5.git] / pp_ctl.c
index d1229af..b49f86d 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2050,7 +2050,8 @@ S_leave_common(pTHX_ SV **newsp, SV **mark, I32 gimme,
        if (MARK < SP) {
             SV *sv = *SP;
 
-           *++newsp = ((SvFLAGS(sv) & flags) && SvREFCNT(sv) == 1)
+           *++newsp = ((SvFLAGS(sv) & flags) && SvREFCNT(sv) == 1
+                         && !SvMAGICAL(sv))
                            ? sv 
                            : lvalue
                                ? sv_2mortal(SvREFCNT_inc_simple_NN(sv))
@@ -2065,7 +2066,8 @@ S_leave_common(pTHX_ SV **newsp, SV **mark, I32 gimme,
        /* in case LEAVE wipes old return values */
        while (++MARK <= SP) {
             SV *sv = *MARK;
-           if ((SvFLAGS(sv) & flags) && SvREFCNT(sv) == 1)
+           if ((SvFLAGS(sv) & flags) && SvREFCNT(sv) == 1
+                         && !SvMAGICAL(sv))
                *++newsp = sv;
            else {
                *++newsp = lvalue
@@ -2335,8 +2337,7 @@ PP(pp_leavesublv)
     if (gimme == G_SCALAR) {
        if (CxLVAL(cx) && !ref) {     /* Leave it as it is if we can. */
            if (MARK <= SP) {
-               if ((SvPADTMP(TOPs) || SvREADONLY(TOPs)) &&
-                   !SvSMAGICAL(TOPs)) {
+               if ((SvPADTMP(TOPs) || SvREADONLY(TOPs))) {
                    what =
                        SvREADONLY(TOPs) ? (TOPs == &PL_sv_undef) ? "undef"
                        : "a readonly value" : "a temporary";