summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2014-12-28 17:07:47 -0800
committerFather Chrysostomos <sprout@cpan.org>2014-12-28 17:08:56 -0800
commitf605e5277bb65662910d4a5b8f8e6ac010f9295a (patch)
tree5b2b6951b300a2b917fdc9cae5e479708ff67c4f
parentadd3e777b167c912c9b05920df015a3763ed4ccd (diff)
downloadperl-f605e5277bb65662910d4a5b8f8e6ac010f9295a.tar.gz
Fix bad write in pp_trans
y/// has not been extending the stack for lexical $_, even since lex- ical $_ was added. $lexical =~ y/// has not been extending the stack since v5.21.5-339-g05a502d.
-rw-r--r--pp.c8
-rw-r--r--t/op/tr.t4
2 files changed, 9 insertions, 3 deletions
diff --git a/pp.c b/pp.c
index 0e011b6446..671bb9b815 100644
--- a/pp.c
+++ b/pp.c
@@ -746,11 +746,13 @@ PP(pp_trans)
if (PL_op->op_flags & OPf_STACKED)
sv = POPs;
- else if (ARGTARG)
- sv = GETTARGET;
else {
- sv = DEFSV;
EXTEND(SP,1);
+ if (ARGTARG)
+ sv = GETTARGET;
+ else {
+ sv = DEFSV;
+ }
}
if(PL_op->op_type == OP_TRANSR) {
STRLEN len;
diff --git a/t/op/tr.t b/t/op/tr.t
index 8a7dd8aafe..c45971a382 100644
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -10,6 +10,10 @@ BEGIN {
plan tests => 134;
+# Test this first before we extend the stack with other operations.
+# This caused an asan failure due to a bad write past the end of the stack.
+eval { my $x; die 1..127, $x =~ y/// };
+
my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1);
$_ = "abcdefghijklmnopqrstuvwxyz";