summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorBen Morrow <ben@morrow.me.uk>2010-08-20 18:35:58 +0100
committerJan Dubois <jand@activestate.com>2010-08-20 15:57:11 -0700
commitd88e091f660036722622a815efa9ef3779605ea6 (patch)
tree653a33d8dc75118b4598d1f9190659693f994f6b /pp.c
parentecf9cdab78811498b3ffea48cfdfb09f678050d2 (diff)
downloadperl-d88e091f660036722622a815efa9ef3779605ea6.tar.gz
Fix my $x = 3; $x = length(undef);.
Assignment of length() to a lexical is optimized by passing the assigned-to variable as TARG, avoiding a pp_padsv and pp_sassign. 9f621b which changed length(undef) to return undef didn't take this into account, and used SETs (which doesn't set TARG), so the code above left $x == 3.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pp.c b/pp.c
index 0da8bba494..fcb7ff2d97 100644
--- a/pp.c
+++ b/pp.c
@@ -3105,8 +3105,10 @@ PP(pp_length)
= sv_2pv_flags(sv, &len,
SV_UNDEF_RETURNS_NULL|SV_CONST_RETURN|SV_GMAGIC);
- if (!p)
- SETs(&PL_sv_undef);
+ if (!p) {
+ sv_setsv(TARG, &PL_sv_undef);
+ SETTARG;
+ }
else if (DO_UTF8(sv)) {
SETi(utf8_length((U8*)p, (U8*)p + len));
}
@@ -3119,7 +3121,8 @@ PP(pp_length)
else
SETi(sv_len(sv));
} else {
- SETs(&PL_sv_undef);
+ sv_setsv_nomg(TARG, &PL_sv_undef);
+ SETTARG;
}
RETURN;
}