If we have a duplicated environment free it
Jarkko Hietaniemi [Thu, 22 Feb 2001 22:13:18 +0000 (22:13 +0000)]
if PERL_DESTRUCT_LEVEL.

p4raw-id: //depot/perl@8896

perl.c

diff --git a/perl.c b/perl.c
index a2538fe..f199e46 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -438,6 +438,20 @@ perl_destruct(pTHXx)
        return;
     }
 
+    /* jettison our possibly duplicated environment */
+
+#ifdef USE_ENVIRON_ARRAY
+    if (environ != PL_origenviron) {
+       I32 i;
+
+       for (i = 0; environ[i]; i++)
+           Safefree(environ[i]);
+       Safefree(environ);
+
+       environ = PL_origenviron;
+    }
+#endif
+
     /* loosen bonds of global variables */
 
     if(PL_rsfp) {