]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770) ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 21 Apr 2025 22:42:55 +0000 (00:42 +0200)
committerGitHub <noreply@github.com>
Mon, 21 Apr 2025 22:42:55 +0000 (22:42 +0000)
gh-132769: Refactor possible read-out-of-bounds in `lexer.c` (GH-132770)
(cherry picked from commit ea8ec95cfadbf58a11ef8e41341254d982a1a479)

Co-authored-by: sobolevn <mail@sobolevn.me>
Parser/lexer/lexer.c

index e4b02aee51d3cf56c5eb592cfdf804915b0e10a9..f7e2359604410931bf49eca14a9f2d5f37781031 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;