# HG changeset patch # User John W. Eaton # Date 1431541028 14400 # Node ID f185653b2f5ea6c8c98e33ce6eb285fb59b899a6 # Parent 4e7f12a763cdfadebe3f4586e3d189c4fed00bcc don't crash if structure field is keyword (bug #45092) * lex.ll (handle_identiier): Emit specific error if structure field is a keyword. Error instead of aborting if at_beginning_of_statement is true when parsting a structure field. diff -r 4e7f12a763cd -r f185653b2f5e libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Tue May 12 10:05:02 2015 -0700 +++ b/libinterp/parse-tree/lex.ll Wed May 13 14:17:08 2015 -0400 @@ -2893,6 +2893,12 @@ std::string tok = yytxt; + // If tok is a keyword token, then is_keyword_token will set + // at_beginning_of_statement. For example, if tok is an IF + // token, then at_beginning_of_statement will be false. + + int kw_token = is_keyword_token (tok); + // If we are expecting a structure element, avoid recognizing // keywords and other special names and return STRUCT_ELT, which is // a string that is also a valid identifier. But first, we have to @@ -2907,17 +2913,22 @@ current_input_column += flex_yyleng (); - assert (! at_beginning_of_statement); + if (kw_token) + { + error ("structure fields may not be keywords"); + return LEXICAL_ERROR; + } + + if (at_beginning_of_statement) + { + error ("invalid syntax for structure reference"); + + return LEXICAL_ERROR; + } return STRUCT_ELT; } - // If tok is a keyword token, then is_keyword_token will set - // at_beginning_of_statement. For example, if tok is and IF - // token, then at_beginning_of_statement will be false. - - int kw_token = is_keyword_token (tok); - if (looking_at_function_handle) { if (kw_token)