In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8d28fc8f69270cc75d9564b369ac6008c5b5d617?hp=7ad03f5069e771fe44e92b694a23f10354c548d1>
- Log ----------------------------------------------------------------- commit 8d28fc8f69270cc75d9564b369ac6008c5b5d617 Author: Matthew Horsfall (alh) <[email protected]> Date: Thu Feb 5 22:24:01 2015 -0500 [perl #123748] - Add test case for possible getenv/putenv/setenv stomping in perl.c ----------------------------------------------------------------------- Summary of changes: t/run/switchd.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/run/switchd.t b/t/run/switchd.t index 5005b082..e210662 100644 --- a/t/run/switchd.t +++ b/t/run/switchd.t @@ -8,7 +8,7 @@ BEGIN { # This test depends on t/lib/Devel/switchd*.pm. -plan(tests => 20); +plan(tests => 21); my $r; @@ -302,3 +302,25 @@ is( "\$DB::single set to overload" ); } + +# [perl #123748] +# +# On some platforms, it's possible that calls to getenv() will +# return a pointer to statically allocated data that may be +# overwritten by subsequent calls to getenv/putenv/setenv/unsetenv. +# +# In perl.c, s = PerlEnv_GetEnv("PERL5OPT") is called, and +# then moreswitches(s), which, if -d:switchd_empty is given, +# will call my_setenv("PERL5DB", "use Devel::switchd_empty"), +# and then return to continue parsing s. +{ +local $ENV{PERL5OPT} = '-d:switchd_empty'; + +like( + runperl( + switches => [ '-Ilib', '-e "print \"hi\""' ], + ), + qr/hi/, + 'putenv does not interfere with PERL5OPT parsing', +); +} -- Perl5 Master Repository
