Re: DBD::Sybase and Sybase::CTlib build problems w/ 5.8.1, Solaris, gcc
[p5sagit/p5-mst-13.2.git] / taint.c
diff --git a/taint.c b/taint.c
index 4ca7ba7..c591e3f 100644 (file)
--- a/taint.c
+++ b/taint.c
@@ -1,6 +1,7 @@
 /*    taint.c
  *
- *    Copyright (c) 1997-2002, Larry Wall
+ *    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ *    2000, 2001, 2002, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -79,7 +80,8 @@ Perl_taint_env(pTHX)
        NULL
     };
 
-    if (!PL_envgv)
+    /* Don't bother if there's no %ENV hash */
+    if (!PL_envgv || !GvHV(PL_envgv))
        return;
 
 #ifdef VMS
@@ -97,7 +99,9 @@ Perl_taint_env(pTHX)
            TAINT;
            taint_proper("Insecure %s%s", "$ENV{DCL$PATH}");
        }
-       if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+       if (SvMAGICAL(*svp)
+               && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+               && MgTAINTEDDIR(mg)) {
            TAINT;
            taint_proper("Insecure directory in %s%s", "$ENV{DCL$PATH}");
        }
@@ -112,7 +116,9 @@ Perl_taint_env(pTHX)
            TAINT;
            taint_proper("Insecure %s%s", "$ENV{PATH}");
        }
-       if ((mg = mg_find(*svp, PERL_MAGIC_envelem)) && MgTAINTEDDIR(mg)) {
+       if (SvMAGICAL(*svp)
+               && (mg = mg_find(*svp, PERL_MAGIC_envelem))
+               && MgTAINTEDDIR(mg)) {
            TAINT;
            taint_proper("Insecure directory in %s%s", "$ENV{PATH}");
        }