]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (#132770)
authorsobolevn <mail@sobolevn.me>
Mon, 21 Apr 2025 17:48:48 +0000 (20:48 +0300)
committerGitHub <noreply@github.com>
Mon, 21 Apr 2025 17:48:48 +0000 (18:48 +0100)
Parser/lexer/lexer.c

index 5e68e5d035c54501d3e70834a69bd899e53aa0ab..e81867a5fad0158f34c94f03bad32ad667a9d141 100644 (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;