diff options
author | Zefram <zefram@fysh.org> | 2010-10-13 21:05:54 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2010-10-21 05:52:52 -0700 |
commit | 805700c1a37c475915b7e2c565a2b4ac1dbe5a97 (patch) | |
tree | 69c7f84531d6402981ab824a30f15cc9763cdac5 /toke.c | |
parent | e4a21daa4e972fdca58792685dc40f8626070430 (diff) | |
download | perl-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.c | 7 |
1 files changed, 1 insertions, 6 deletions
@@ -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 = |