summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-02-10 09:20:14 -0800
committerFather Chrysostomos <sprout@cpan.org>2011-02-10 09:20:49 -0800
commite27c778fa5810b784abf1dc38af460227e408d37 (patch)
tree00e608d0bde97e52a3ee8f5094e58e05b5339801 /pp.c
parent9a0dc6e4c3a9ae91c1101b1179e22c93bb77a4cb (diff)
downloadperl-e27c778fa5810b784abf1dc38af460227e408d37.tar.gz
[perl #77692] substr causes panic: sv_len_utf8 cache...
pp_substr contains this comment, which was added in perl 5.0 alpha 2 (commit 79072805bf63): PUSHs(TARG); /* avoid SvSETMAGIC here */ Calling set-magic when substr returns an lvalue will cause its argu- ment to be stringified even if the lvalue is not assigned to. That’s why set-magic has to be avoided. But the result is that utf8 caches (stored in magic) on TARG are not reset properly. Since substr lvalues now follow a different code path (and do not use TARG at all), it’s perfectly safe to call set-magic at this point. It’s also the right thing to do in case of other types of magic that might get attached to TARG.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index d2bb466c1c..d857c7e916 100644
--- a/pp.c
+++ b/pp.c
@@ -3540,7 +3540,8 @@ PP(pp_substr)
}
}
SPAGAIN;
- PUSHs(TARG); /* avoid SvSETMAGIC here */
+ SvSETMAGIC(TARG);
+ PUSHs(TARG);
RETURN;
bound_fail: