From 8d6cf4ebe48880408d0dddcfe8019aad8b816c27 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 27 Sep 2010 18:51:22 -0700 Subject: [PATCH] lexer: Properly initialize lexer->prog when lex_get_line_raw() fails. lex_get_line(), the main caller of lex_get_line_raw(), set lexer->prog to NULL when reading failed, but other callers need to do the same thing too, otherwise e.g. DO REPEAT accesses invalid storage when there is a missing END REPEAT. Bug #31016. --- src/language/lexer/lexer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index aa681c80..87fecaa6 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -862,6 +862,8 @@ lex_get_line_raw (struct lexer *lexer) const char *line = ds_cstr (&lexer->line_buffer); text_item_submit (text_item_create (TEXT_ITEM_SYNTAX, line)); } + else + lexer->prog = NULL; return ok; } @@ -874,10 +876,7 @@ lex_get_line (struct lexer *lexer) bool line_starts_command; if (!lex_get_line_raw (lexer)) - { - lexer->prog = NULL; - return false; - } + return false; lex_preprocess_line (&lexer->line_buffer, lex_current_syntax_mode (lexer), -- 2.30.2