From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Thu, 22 Feb 2001 22:13:18 +0000 (+0000)
Subject: If we have a duplicated environment free it
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=551a8b838dd0aec11f1a7553b070651ef7bd1a24;p=p5sagit%2Fp5-mst-13.2.git

If we have a duplicated environment free it
if PERL_DESTRUCT_LEVEL.

p4raw-id: //depot/perl@8896
---

diff --git a/perl.c b/perl.c
index a2538fe..f199e46 100644
--- 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) {