mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 06:13:02 +00:00
fix: unterminated \-escape
An assertion failed when the last character is a '\' and we're in a character or a string. Reported by Agency for Defense Development. https://lists.gnu.org/r/bug-bison/2020-08/msg00009.html * src/scan-gram.l: Catch unterminated escapes. * tests/input.at (Unexpected end of file): New.
This commit is contained in:
@@ -567,6 +567,8 @@ eqopt ({sp}=)?
|
||||
_("POSIX Yacc does not support string literals"));
|
||||
RETURN_VALUE (STRING, last_string);
|
||||
}
|
||||
<<EOF>> unexpected_eof (token_start, "\"");
|
||||
"\n" unexpected_newline (token_start, "\"");
|
||||
}
|
||||
|
||||
<SC_ESCAPED_TSTRING>
|
||||
@@ -580,13 +582,10 @@ eqopt ({sp}=)?
|
||||
_("POSIX Yacc does not support string literals"));
|
||||
RETURN_VALUE (TSTRING, last_string);
|
||||
}
|
||||
<<EOF>> unexpected_eof (token_start, "\")");
|
||||
"\n" unexpected_newline (token_start, "\")");
|
||||
}
|
||||
|
||||
<SC_ESCAPED_STRING,SC_ESCAPED_TSTRING>
|
||||
{
|
||||
<<EOF>> unexpected_eof (token_start, "\"");
|
||||
"\n" unexpected_newline (token_start, "\"");
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------.
|
||||
@@ -692,6 +691,15 @@ eqopt ({sp}=)?
|
||||
p);
|
||||
STRING_1GROW ('?');
|
||||
}
|
||||
|
||||
"\\" {
|
||||
// None of the other rules matched: the last character of this
|
||||
// file is "\". But Flex does not support "\\<<EOF>>".
|
||||
unexpected_eof (token_start,
|
||||
YY_START == SC_ESCAPED_CHARACTER ? "?'"
|
||||
: YY_START == SC_ESCAPED_STRING ? "?\""
|
||||
: "?\")");
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------.
|
||||
|
||||
Reference in New Issue
Block a user