10000 bpo-40880: Fix invalid read in newline_in_string in pegen.c (GH-20666) · python/cpython@15fec56 · GitHub
[go: up one dir, main page]

Skip to content

Commit 15fec56

Browse files
bpo-40880: Fix invalid read in newline_in_string in pegen.c (GH-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> (cherry picked from commit 2e6593d) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent 79e6c15 commit 15fec56

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
@@ -936,8 +936,8 @@ _PyPegen_number_token(Parser *p)
936936
static int // bool
937937
newline_in_string(Parser *p, const char *cur)
938938
{
939-
for (char c = *cur; cur >= p->tok->buf; c = *--cur) {
940-
if (c == '\'' || c == '"') {
939+
for (const char *c = cur; c >= p->tok->buf; c--) {
940+
if (*c == '\'' || *c == '"') {
941941
return 1;
942942
}
943943
}

0 commit comments

Comments
 (0)
0