[perl #34076] P/p pack formats only recognize literal undef
perl-5.8.0@ton.iguana.be [Sun, 6 Feb 2005 22:03:20 +0000 (22:03 +0000)]
From: perl-5.8.0@ton.iguana.be (via RT) <perlbug-followup@perl.org>
Message-ID: <rt-3.0.11-34076-107344.19.3123360602169@perl.org>

p4raw-id: //depot/perl@23951

pp_pack.c

index 690cd35..0cabe92 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2685,8 +2685,8 @@ S_pack_rec(pTHX_ SV *cat, register tempsym_t* symptr, register SV **beglist, SV
        case 'p':
            while (len-- > 0) {
                fromstr = NEXTFROM;
-               if (fromstr == &PL_sv_undef)
-                   aptr = NULL;
+               SvGETMAGIC(fromstr);
+               if (!SvOK(fromstr)) aptr = NULL;
                else {
                    STRLEN n_a;
                    /* XXX better yet, could spirit away the string to
@@ -2702,9 +2702,9 @@ S_pack_rec(pTHX_ SV *cat, register tempsym_t* symptr, register SV **beglist, SV
                                "Attempt to pack pointer to temporary value");
                    }
                    if (SvPOK(fromstr) || SvNIOK(fromstr))
-                       aptr = SvPV(fromstr,n_a);
+                       aptr = SvPV_flags(fromstr, n_a, 0);
                    else
-                       aptr = SvPV_force(fromstr,n_a);
+                       aptr = SvPV_force_flags(fromstr, n_a, 0);
                }
                DO_BO_PACK_P(aptr);
                sv_catpvn(cat, (char*)&aptr, sizeof(char*));