mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
bpo-42150: Avoid buffer overflow in the new parser (GH-22978)
This commit is contained in:
parent
d1a0a960ee
commit
e68c67805e
2 changed files with 4 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
Fix possible buffer overflow in the new parser when checking for
|
||||||
|
continuation lines. Patch by Pablo Galindo.
|
|
@ -990,7 +990,8 @@ bad_single_statement(Parser *p)
|
||||||
|
|
||||||
/* Newlines are allowed if preceded by a line continuation character
|
/* Newlines are allowed if preceded by a line continuation character
|
||||||
or if they appear inside a string. */
|
or if they appear inside a string. */
|
||||||
if (!cur || *(cur - 1) == '\\' || newline_in_string(p, cur)) {
|
if (!cur || (cur != p->tok->buf && *(cur - 1) == '\\')
|
||||||
|
|| newline_in_string(p, cur)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
char c = *cur;
|
char c = *cur;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue