mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
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 2e6593db00)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
79e6c15aed
commit
15fec5627a
2 changed files with 4 additions and 2 deletions
|
|
@ -0,0 +1,2 @@
|
|||
Fix invalid memory read in the new parser when checking newlines in string
|
||||
literals. Patch by Pablo Galindo.
|
||||
|
|
@ -936,8 +936,8 @@ _PyPegen_number_token(Parser *p)
|
|||
static int // bool
|
||||
newline_in_string(Parser *p, const char *cur)
|
||||
{
|
||||
for (char c = *cur; cur >= p->tok->buf; c = *--cur) {
|
||||
if (c == '\'' || c == '"') {
|
||||
for (const char *c = cur; c >= p->tok->buf; c--) {
|
||||
if (*c == '\'' || *c == '"') {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue