From: Rafael Garcia-Suarez Date: Wed, 5 Apr 2006 19:45:42 +0000 (+0000) Subject: Assigning undef to an entry in %ENV shouldn't produce warnings, even X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ae3433d9acf2239ad936d472a709712f4962dc3;p=p5sagit%2Fp5-mst-13.2.git Assigning undef to an entry in %ENV shouldn't produce warnings, even though it's silently converted to "" p4raw-id: //depot/perl@27725 --- diff --git a/mg.c b/mg.c index 268e067..82f63c0 100644 --- 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); diff --git a/t/lib/warnings/mg b/t/lib/warnings/mg index c6d7506..2e2d4aa 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