This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Assigning undef to an entry in %ENV shouldn't produce warnings, even
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 268e067..82f63c0 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -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);