From: Ben Pfaff Date: Sat, 16 Apr 2011 18:20:59 +0000 (-0700) Subject: gui: Fix crash in executor when inline data is missing. X-Git-Tag: v0.7.8~58 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e63296a3c2bfcf1b40d712e79f17b349c4a6f21d;p=pspp-builds.git gui: Fix crash in executor when inline data is missing. Without this commit, typing "DATA LIST /x 1." into an otherwise empty syntax window and executing it caused a crash because the lexer was being accessed after it was destroyed. This commit averts the crash. --- diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index 6377107c..123000fe 100644 --- a/src/ui/gui/executor.c +++ b/src/ui/gui/executor.c @@ -90,9 +90,6 @@ execute_syntax (struct lex_reader *lex_reader) break; } - lex_destroy (lexer); - psppire_set_lexer (NULL); - proc_execute (the_dataset); psppire_dict_replace_dictionary (the_data_store->dict, @@ -102,6 +99,13 @@ execute_syntax (struct lex_reader *lex_reader) if (!lazy_casereader_destroy (reader, lazy_serial)) psppire_data_store_set_reader (the_data_store, reader); + /* Destroy the lexer only after obtaining the dataset, because the dataset + might depend on the lexer, if the casereader specifies inline data. (In + such a case then we'll always get an error message--the inline data is + missing, otherwise it would have been parsed in the loop above.) */ + lex_destroy (lexer); + psppire_set_lexer (NULL); + output_flush (); return retval;