Fix condition for assuming at EOF

Part of that condition's purpose is to ensure that we read the correct
lexer state; but it's possible now for the fstack to be non-empty
*before* the lexer state is registered, i.e. if there is an error
in the function that registers it.
This causes a NULL pointer deref.
This commit is contained in:
ISSOtm
2024-09-05 15:24:17 +02:00
parent e289387b09
commit 610f04beeb
7 changed files with 19 additions and 5 deletions

View File

@@ -338,6 +338,10 @@ static bool isWhitespace(int c) {
static LexerState *lexerState = nullptr;
static LexerState *lexerStateEOL = nullptr;
bool lexer_AtTopLevel() {
return lexerState == nullptr;
}
void LexerState::clear(uint32_t lineNo_) {
mode = LEXER_NORMAL;
atLineStart = true; // yylex() will init colNo due to this