From: Ben Pfaff Date: Tue, 28 Sep 2010 01:51:22 +0000 (-0700) Subject: lexer: Properly initialize lexer->prog when lex_get_line_raw() fails. X-Git-Tag: v0.7.6~149 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d6cf4ebe48880408d0dddcfe8019aad8b816c27;p=pspp-builds.git 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. --- 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),