• aperez's avatar
    Parser: Fix crash on stack overflow when lazy-parsing arrow functions · 3c3ce1bc
    aperez authored
    The problem manifests itself when parsing manages to return something
    meaningful in the presence of a stack overflow. This happens because
    calling ParserBase::Next() will still return one valid token on stack
    overflow, before starting to return invalid tokens.
    
    Take the following input as example:
    
            a.map(v => v + 1);
                  | |
           already   next token
            parsed   (which will be an invalid token
      (identifier)   because of a stack overflow)
    
    The "v" may have been already parsed into a VariableProxy, then if a
    stack overflow occurs, next token will be an invalid token (instead
    of Token::ARROW), but the parser will return the VariableProxy.
    
    This always happens when lazy-parsing arrow functions, so the position
    in the input stream where the the arrow function code ends is known.
    This fix adds a check that ensures that parsing ended at the end
    position of the arrow function.
    
    BUG=465671
    LOG=N
    
    Review URL: https://codereview.chromium.org/1023483003
    
    Cr-Commit-Position: refs/heads/master@{#27325}
    3c3ce1bc
Name
Last commit
Last update
benchmarks Loading commit data...
build Loading commit data...
include Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party/binutils Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
Makefile.nacl Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...