Update be_lexer.c (#19856)

Added check for unterminated block comments
This commit is contained in:
Andreas Ziemer 2023-10-28 11:43:35 +02:00 committed by GitHub
parent 18c56f92bb
commit dfa6f9a771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -260,6 +260,7 @@ static void skip_comment(blexer *lexer)
{
next(lexer); /* skip '#' */
if (lgetc(lexer) == '-') { /* mult-line comment */
int lno = lexer->linenumber;
int mark, c = 'x'; /* skip first '-' (#- ... -#) */
do {
mark = c == '-';
@ -269,6 +270,11 @@ static void skip_comment(blexer *lexer)
}
c = next(lexer);
} while (!(mark && c == '#') && c != EOS);
if (c == EOS) {
char tmp[64];
sprintf(tmp, "unterminated comment block started in line %d", lno);
be_lexerror(lexer, tmp);
}
next(lexer); /* skip '#' */
} else { /* line comment */
while (!is_newline(lgetc(lexer)) && lgetc(lexer)) {