[proposed PATCH] correctly unlocalise exists on tied/%ENV
[p5sagit/p5-mst-13.2.git] / util.c
diff --git a/util.c b/util.c
index 6b95a4d..fe93c99 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1113,9 +1113,10 @@ Perl_vmess(pTHX_ const char *pat, va_list *args)
            bool line_mode = (RsSIMPLE(PL_rs) &&
                              SvCUR(PL_rs) == 1 && *SvPVX(PL_rs) == '\n');
            Perl_sv_catpvf(aTHX_ sv, ", <%s> %s %"IVdf,
-                     PL_last_in_gv == PL_argvgv ? "" : GvNAME(PL_last_in_gv),
-                     line_mode ? "line" : "chunk",
-                     (IV)IoLINES(GvIOp(PL_last_in_gv)));
+                          PL_last_in_gv == PL_argvgv ?
+                          "" : GvNAME(PL_last_in_gv),
+                          line_mode ? "line" : "chunk",
+                          (IV)IoLINES(GvIOp(PL_last_in_gv)));
        }
 #ifdef USE_5005THREADS
        if (thr->tid)
@@ -1593,6 +1594,11 @@ Perl_vwarner(pTHX_ U32  err, const char* pat, va_list* args)
 void
 Perl_my_setenv(pTHX_ char *nam, char *val)
 {
+#ifdef USE_ITHREADS
+  /* only parent thread can modify process environment */
+  if (PL_curinterp == aTHX)
+#endif
+  {
 #ifndef PERL_USE_SAFE_PUTENV
     /* most putenv()s leak, so we manipulate environ directly */
     register I32 i=setenv_getix(nam);          /* where does it go? */
@@ -1651,6 +1657,7 @@ Perl_my_setenv(pTHX_ char *nam, char *val)
     (void)putenv(new_env);
 #   endif /* __CYGWIN__ */
 #endif  /* PERL_USE_SAFE_PUTENV */
+  }
 }
 
 #else /* WIN32 || NETWARE */
@@ -3447,7 +3454,8 @@ Perl_report_evil_fh(pTHX_ GV *gv, IO *io, I32 op)
     if (gv && isGV(gv)) {
        SV *sv = sv_newmortal();
        gv_efullname4(sv, gv, Nullch, FALSE);
-       name = SvPVX(sv);
+        if (SvOK(sv))
+            name = SvPVX(sv);
     }
 
     if (op == OP_phoney_OUTPUT_ONLY || op == OP_phoney_INPUT_ONLY) {