summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2016-09-08 13:21:02 +1000
committerTony Cook <tony@develop-help.com>2017-01-24 15:24:40 +1100
commit743e3e72117ab1d168cbf4ef15bcde67ca41e26a (patch)
tree67137bf691dc2a66090103686c7913ff6e49984c /toke.c
parentbab2353254d7670be3a83e4e63b0a5b0e412b6e1 (diff)
downloadperl-743e3e72117ab1d168cbf4ef15bcde67ca41e26a.tar.gz
(perl #129190) intuit_method() can move the line buffer
and broke PL_bufptr when it did.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index ca06b7a3ab..0e02fd51cf 100644
--- a/toke.c
+++ b/toke.c
@@ -4276,13 +4276,14 @@ S_intuit_method(pTHX_ char *start, SV *ioname, CV *cv)
}
if (*start == '$') {
+ SSize_t start_off = start - SvPVX(PL_linestr);
if (cv || PL_last_lop_op == OP_PRINT || PL_last_lop_op == OP_SAY
|| isUPPER(*PL_tokenbuf))
return 0;
/* this could be $# */
if (isSPACE(*s))
s = skipspace(s);
- PL_bufptr = start;
+ PL_bufptr = SvPVX(PL_linestr) + start_off;
PL_expect = XREF;
return *s == '(' ? FUNCMETH : METHOD;
}
@@ -7262,17 +7263,24 @@ Perl_yylex(pTHX)
== OA_FILEREF))
{
bool immediate_paren = *s == '(';
+ SSize_t s_off;
/* (Now we can afford to cross potential line boundary.) */
s = skipspace(s);
+ /* intuit_method() can indirectly call lex_next_chunk(),
+ * invalidating s
+ */
+ s_off = s - SvPVX(PL_linestr);
/* Two barewords in a row may indicate method call. */
if ( ( isIDFIRST_lazy_if_safe(s, PL_bufend, UTF)
|| *s == '$')
&& (tmp = intuit_method(s, lex ? NULL : sv, cv)))
{
+ /* the code at method: doesn't use s */
goto method;
}
+ s = SvPVX(PL_linestr) + s_off;
/* If not a declared subroutine, it's an indirect object. */
/* (But it's an indir obj regardless for sort.) */