From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 21 Apr 2025 22:42:55 +0000 (+0200) Subject: [3.13] gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770) ... X-Git-Tag: v3.13.4~240 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e140e6ef789b1d8de1afd715503740e96e5ae925;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770) (#132788) gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770) (cherry picked from commit ea8ec95cfadbf58a11ef8e41341254d982a1a479) Co-authored-by: sobolevn --- diff --git a/Parser/lexer/lexer.c b/Parser/lexer/lexer.c index e4b02aee51d3..f7e235960441 100644 --- a/Parser/lexer/lexer.c +++ b/Parser/lexer/lexer.c @@ -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;