summaryrefslogtreecommitdiff
path: root/src/scan-gram.l
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-07-28 18:51:30 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-07-28 19:01:48 +0200
commitbe95a4fe2951374676efc9454ffee8638faaf68d (patch)
treea06712b16c6e990cf4cb1e500b99dcccac9686e3 /src/scan-gram.l
parent6accee7716294afd2e0a9b644935274c5ae6bdb0 (diff)
downloadbison-be95a4fe2951374676efc9454ffee8638faaf68d.tar.gz
scanner: don't crash on strings containing a NUL byte
We crash if the input contains a string containing a NUL byte. Reported by Suhwan Song. https://lists.gnu.org/r/bug-bison/2020-07/msg00051.html * src/flex-scanner.h (STRING_FREE): Avoid accidental use of last_string. * src/scan-gram.l: Don't call STRING_FREE without calling STRING_FINISH first. * tests/input.at (Invalid inputs): Check that case.
Diffstat (limited to 'src/scan-gram.l')
-rw-r--r--src/scan-gram.l3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/scan-gram.l b/src/scan-gram.l
index f8d85f23..ad2904ce 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -403,6 +403,7 @@ eqopt ({sp}=)?
{
\0 {
complain (loc, complaint, _("invalid null character"));
+ STRING_FINISH ();
STRING_FREE ();
return GRAM_error;
}
@@ -599,7 +600,6 @@ eqopt ({sp}=)?
STRING_FINISH ();
BEGIN INITIAL;
loc->start = token_start;
- val->CHAR = last_string[0];
if (last_string[0] == '\0')
{
@@ -615,6 +615,7 @@ eqopt ({sp}=)?
}
else
{
+ val->CHAR = last_string[0];
STRING_FREE ();
return CHAR;
}