summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorMerijn Broeren <merijnb@iloquent.nl>2004-09-23 19:18:17 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-09-28 15:28:58 +0000
commit9b4eeda5ae692087a98457d63c818ddb127a1327 (patch)
tree25c5509f2f3eae3613bbd2c36973eb1f0a8eabaa /perl.c
parent401441c0a1ebb6ac9c38237eb5daa1c00cea8bb6 (diff)
downloadperl-9b4eeda5ae692087a98457d63c818ddb127a1327.tar.gz
Patch for perl.c fixing an obscure environment bug
Message-ID: <20040923151817.GA15782@brugman.iloquent.nl> p4raw-id: //depot/perl@23337
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/perl.c b/perl.c
index 957bbbc0e0..41c538aaf1 100644
--- a/perl.c
+++ b/perl.c
@@ -4097,9 +4097,10 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
{
environ[0] = Nullch;
}
- if (env)
+ if (env) {
+ char** origenv = environ;
for (; *env; env++) {
- if (!(s = strchr(*env,'=')))
+ if (!(s = strchr(*env,'=')) || s == *env)
continue;
#if defined(MSDOS) && !defined(DJGPP)
*s = '\0';
@@ -4110,7 +4111,13 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
(void)hv_store(hv, *env, s - *env, sv, 0);
if (env != environ)
mg_set(sv);
+ if (origenv != environ) {
+ /* realloc has shifted us */
+ env = (env - origenv) + environ;
+ origenv = environ;
+ }
}
+ }
#endif /* USE_ENVIRON_ARRAY */
#endif /* !PERL_MICRO */
}