diff options
-rw-r--r-- | mg.c | 4 | ||||
-rw-r--r-- | t/lib/warnings/mg | 5 |
2 files changed, 7 insertions, 2 deletions
@@ -1042,8 +1042,8 @@ int Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) { dVAR; - STRLEN len, klen; - const char *s = SvPV_const(sv,len); + STRLEN len = 0, klen; + const char *s = SvOK(sv) ? SvPV_const(sv,len) : ""; const char * const ptr = MgPV_const(mg,klen); my_setenv(ptr, s); diff --git a/t/lib/warnings/mg b/t/lib/warnings/mg index c6d7506be2..2e2d4aa0f3 100644 --- a/t/lib/warnings/mg +++ b/t/lib/warnings/mg @@ -55,3 +55,8 @@ use warnings 'uninitialized'; length $3; EXPECT Use of uninitialized value $3 in length at - line 3. +######## +# mg.c +use warnings 'uninitialized'; +$ENV{FOO} = undef; # should not warn +EXPECT |