8000 bpo-40880: Fix invalid read in newline_in_string in pegen.c (#20666) · python/cpython@2e6593d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2e6593d

Browse files
bpo-40880: Fix invalid read in newline_in_string in pegen.c (#20666)
* bpo-40880: Fix invalid read in newline_in_string in pegen.c * Update Parser/pegen/pegen.c Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> * Add NEWS entry Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
1 parent a54096e commit 2e6593d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix invalid memory read in the new parser when checking newlines in string
2+
literals. Patch by Pablo Galindo.

Parser/pegen/pegen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,8 @@ _PyPegen_number_token(Parser *p)
937937
static int // bool
938938
newline_in_string(Parser *p, const char *cur)
939939
{
940-
for (char c = *cur; cur >= p->tok->buf; c = *--cur) {
941-
if (c == '\'' || c == '"') {
940+
for (const char *c = cur; c >= p->tok->buf; c--) {
941+
if (*c == '\'' || *c == '"') {
942942
return 1;
943943
}
944944
}

0 commit comments

Comments
 (0)
0