summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorDavid Leadbeater <dgl@dgl.cx>2011-03-06 15:19:57 +0000
committerFather Chrysostomos <sprout@cpan.org>2011-03-06 13:13:14 -0800
commit9407f9c16f7d184b9b5524ddf3659d961e6a5f14 (patch)
tree23c0233fcbbc3b70b0190a5b2310280f91439a96 /pp.c
parentab08a362aba1ac5dacd58ee13d77e9faf693e7e3 (diff)
downloadperl-9407f9c16f7d184b9b5524ddf3659d961e6a5f14.tar.gz
Fix [perl #85508] regression in print length undef
length was returning a temporary copy of undef, this meant it didn't generate a warning when used uninitialised. Return PL_sv_undef but also ensure TARG is cleared if needed.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index d6f03322f2..4bf4b181f1 100644
--- a/pp.c
+++ b/pp.c
@@ -3330,8 +3330,11 @@ PP(pp_length)
SV_UNDEF_RETURNS_NULL|SV_CONST_RETURN|SV_GMAGIC);
if (!p) {
- sv_setsv(TARG, &PL_sv_undef);
- SETTARG;
+ if (!SvPADTMP(TARG)) {
+ sv_setsv(TARG, &PL_sv_undef);
+ SETTARG;
+ }
+ SETs(&PL_sv_undef);
}
else if (DO_UTF8(sv)) {
SETi(utf8_length((U8*)p, (U8*)p + len));
@@ -3345,8 +3348,11 @@ PP(pp_length)
else
SETi(sv_len(sv));
} else {
- sv_setsv_nomg(TARG, &PL_sv_undef);
- SETTARG;
+ if (!SvPADTMP(TARG)) {
+ sv_setsv_nomg(TARG, &PL_sv_undef);
+ SETTARG;
+ }
+ SETs(&PL_sv_undef);
}
RETURN;
}