Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[[FIX]] Avoid crash when peeking past end of prog (#2937)
The lexer returns `null` values when tokens are requested after all input has been consumed. Previously, the `peek` function would correctly produce the special "(end)" token in situations where the parser attempted to look beyond the end of the program. In such cases, however, it would also pollute the lookahead buffer with an invalid entry--the `null` value returned by the lexer. Future calls to `peek` could receive this buffered value. Because JSHint's internals are written with the assumption that `peek` always returns a token object, the `null` value would trigger a TypeError and subsequent program crash. Re-factor the `peek` function to only insert valid token objects into the lookahead buffer.
- Loading branch information