From: Merijn Broeren Date: Thu, 23 Sep 2004 17:18:17 +0000 (+0200) Subject: Patch for perl.c fixing an obscure environment bug X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b4eeda5ae692087a98457d63c818ddb127a1327;p=p5sagit%2Fp5-mst-13.2.git Patch for perl.c fixing an obscure environment bug Message-ID: <20040923151817.GA15782@brugman.iloquent.nl> p4raw-id: //depot/perl@23337 --- diff --git a/perl.c b/perl.c index 957bbbc..41c538a 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 */ }