Upgrade to Compress::Zlib 1.38
[p5sagit/p5-mst-13.2.git] / mg.c
diff --git a/mg.c b/mg.c
index 65d565d..d3a001a 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1045,10 +1045,13 @@ Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg)
        MgTAINTEDDIR_off(mg);
 #ifdef VMS
        if (s && klen == 8 && strEQ(ptr, "DCL$PATH")) {
-           char pathbuf[256], eltbuf[256], *cp, *elt = (char *) s;
+           char pathbuf[256], eltbuf[256], *cp, *elt;
            Stat_t sbuf;
            int i = 0, j = 0;
 
+           strncpy(eltbuf, s, 255);
+           eltbuf[255] = 0;
+           elt = eltbuf;
            do {          /* DCL$PATH may be a search list */
                while (1) {   /* as may dev portion of any element */
                    if ( ((cp = strchr(elt,'[')) || (cp = strchr(elt,'<'))) ) {
@@ -2712,8 +2715,8 @@ Perl_sighandler(int sig)
                    * addr, status, and band are defined by POSIX/SUSv3. */
                   hv_store(sih, "signo",   5, newSViv(sip->si_signo),  0);
                   hv_store(sih, "code",    4, newSViv(sip->si_code),   0);
-                  hv_store(sih, "errno",   5, newSViv(sip->si_errno),  0);
 #if 0 /* XXX TODO: Configure scan for the existence of these, but even that does not help if the SA_SIGINFO is not implemented according to the spec. */
+                  hv_store(sih, "errno",   5, newSViv(sip->si_errno),  0);
                   hv_store(sih, "status",  6, newSViv(sip->si_status), 0);
                   hv_store(sih, "uid",     3, newSViv(sip->si_uid),    0);
                   hv_store(sih, "pid",     3, newSViv(sip->si_pid),    0);
@@ -2790,8 +2793,16 @@ S_restore_magic(pTHX_ const void *p)
            SvFLAGS(sv) |= mgs->mgs_flags;
        else
            mg_magical(sv);
-       if (SvGMAGICAL(sv))
-           SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK|SVf_POK);
+       if (SvGMAGICAL(sv)) {
+           /* downgrade public flags to private,
+              and discard any other private flags */
+
+           U32 public = SvFLAGS(sv) & (SVf_IOK|SVf_NOK|SVf_POK);
+           if (public) {
+               SvFLAGS(sv) &= ~( public | SVp_IOK|SVp_NOK|SVp_POK );
+               SvFLAGS(sv) |= ( public << PRIVSHIFT );
+           }
+       }
     }
 
     mgs->mgs_sv = NULL;  /* mark the MGS structure as restored */