gh-132769: Refactor possible read-out-of-bounds in lexer.c (#132770)

This commit is contained in:
sobolevn 2025-04-21 20:48:48 +03:00 committed by GitHub
parent 8516343d3a
commit ea8ec95cfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -140,7 +140,7 @@ set_fstring_expr(struct tok_state* tok, struct token *token, char c) {
for (i = 0, j = 0; i < input_length; i++) {
if (tok_mode->last_expr_buffer[i] == '#') {
// Skip characters until newline or end of string
while (tok_mode->last_expr_buffer[i] != '\0' && i < input_length) {
while (i < input_length && tok_mode->last_expr_buffer[i] != '\0') {
if (tok_mode->last_expr_buffer[i] == '\n') {
result[j++] = tok_mode->last_expr_buffer[i];
break;