Skip to content

Commit e822876

Browse files
committed
Do not permit empty bitstrings
1 parent 143c292 commit e822876

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/lexer.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,19 @@ Token Lexer::computeNextToken()
239239
{
240240
case 'b':
241241
pushToToken(ch);
242-
// parse [01]*
243-
parseCharList(CharacterClass::BIT);
242+
// parse [01]+
243+
if (!parseNonEmptyCharList(CharacterClass::BIT))
244+
{
245+
parseError("Error expected bit string");
246+
}
244247
return Token::BINARY_LITERAL;
245248
case 'x':
246249
pushToToken(ch);
247-
// parse [0-9a-fA-F]*
248-
parseCharList(CharacterClass::HEXADECIMAL_DIGIT);
250+
// parse [0-9a-fA-F]+
251+
if (!parseNonEmptyCharList(CharacterClass::HEXADECIMAL_DIGIT))
252+
{
253+
parseError("Error expected hexadecimal string");
254+
}
249255
return Token::HEX_LITERAL;
250256
default:
251257
// otherwise error

0 commit comments

Comments
 (0)