summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/perl.c b/perl.c
index a2538fe5c6..f199e4656f 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) {