summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-10-13 21:05:54 +0100
committerFather Chrysostomos <sprout@cpan.org>2010-10-21 05:52:52 -0700
commit805700c1a37c475915b7e2c565a2b4ac1dbe5a97 (patch)
tree69c7f84531d6402981ab824a30f15cc9763cdac5 /toke.c
parente4a21daa4e972fdca58792685dc40f8626070430 (diff)
downloadperl-805700c1a37c475915b7e2c565a2b4ac1dbe5a97.tar.gz
avoid side-effecting source held in scalar
Syntax plugins can modify the source being parsed. It's fine for them to modify the lexer buffer, but this must not be the same scalar that was supplied to lex_start() and may be in use outside. Therefore always copy the scalar in lex_start() rather than just referencing it. Fixes [perl #78358].
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/toke.c b/toke.c
index fa1882dcef..99aae57f3e 100644
--- a/toke.c
+++ b/toke.c
@@ -704,15 +704,10 @@ Perl_lex_start(pTHX_ SV *line, PerlIO *rsfp)
if (!len) {
parser->linestr = newSVpvs("\n;");
- } else if (SvREADONLY(line) || s[len-1] != ';' || !SvPOK(line)) {
- /* avoid tie/overload weirdness */
+ } else {
parser->linestr = newSVpvn_flags(s, len, SvUTF8(line));
if (s[len-1] != ';')
sv_catpvs(parser->linestr, "\n;");
- } else {
- SvTEMP_off(line);
- SvREFCNT_inc_simple_void_NN(line);
- parser->linestr = line;
}
parser->oldoldbufptr =
parser->oldbufptr =