Skip to content

Commit ac4d84e

Browse files
committed
intuit_more: 0 length identifier means nothing more
If scan_ident indicates that $ @ & are followed by nothing that looks like an identifier, then this isn't an expression. It has to be a character class or an error. Almost anything is an identifier when 'use utf8' isn't in effect; when it is, non ASCII has to be an Identifier Start character following these
1 parent b61e5b8 commit ac4d84e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

toke.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4751,6 +4751,13 @@ S_intuit_more(pTHX_ char *s, char *e,
47514751
Size_t len; /* (C++ forbids joining these 2 lines) */
47524752
len = strlen(tmpbuf + 1);
47534753

4754+
/* If it doesn't look like an identifier at all, scan_ident will
4755+
* set tmpbuf[1] to NUL. This is either an error or a character
4756+
* class. */
4757+
if (len == 0) {
4758+
return false;
4759+
}
4760+
47544761
/* khw: This only looks at global variables; lexicals came
47554762
* later, and this hasn't been updated. Ouch!! */
47564763
if ( len > 1
@@ -4772,10 +4779,9 @@ S_intuit_more(pTHX_ char *s, char *e,
47724779
* element, like $subscripts{$which}. We should advance
47734780
* past the braces and key */
47744781
}
4775-
else /* len == 1 */
4776-
if ( s[0] == '$'
4777-
&& s[1]
4778-
&& memCHRs("[#!%*<>()-=", tmpbuf[1]))
4782+
else if ( len == 1
4783+
&& s[0] == '$'
4784+
&& memCHRs("[#!%*<>()-=", tmpbuf[1]))
47794785
{
47804786
/* Here we have what could be a punctuation variable. If the
47814787
* next character after it is a closing bracket, it makes it
@@ -4786,7 +4792,7 @@ S_intuit_more(pTHX_ char *s, char *e,
47864792
else
47874793
weight -= 1;
47884794
}
4789-
else { /* len == 1 */
4795+
else {
47904796
/* Not a multi-char identifier already known in the program;
47914797
* is somewhat likely to be a subscript.
47924798
*

0 commit comments

Comments
 (0)