summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-22 07:41:39 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-22 07:41:39 +0100
commitdcb21ed695e1607e7f38d24d60022fda943f55e2 (patch)
tree1fa33fb1ff2823b03863e83de062bf636253a9d9 /toke.c
parentc678e61761316cef95aa1177d92c245639595161 (diff)
downloadperl-dcb21ed695e1607e7f38d24d60022fda943f55e2.tar.gz
S_tokeq()'s fast scan loop should terminate on \\ not \
As-was, it would drop out of the scanner into the backslashed-backslash processing loop earlier than need be, and hence would be copying the octets of strings (in place) as soon as any backslash had been seen. Now it defers copying until copying is actually unavoidable.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index 731c2b4d35..b6f9cc916e 100644
--- a/toke.c
+++ b/toke.c
@@ -2253,7 +2253,8 @@ S_tokeq(pTHX_ SV *sv)
if (SvTYPE(sv) >= SVt_PVIV && SvIVX(sv) == -1)
goto finish;
send = s + len;
- while (s < send && *s != '\\')
+ /* This is relying on the SV being "well formed" with a trailing '\0' */
+ while (s < send && !(*s == '\\' && s[1] == '\\'))
s++;
if (s == send)
goto finish;