summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2020-10-25 23:24:56 (GMT)
committerGitHub <noreply@github.com>2020-10-25 23:24:56 (GMT)
commit0b290dd2171e745d94f48298cafb2327eb2de17c (patch)
tree9d0bb1f152397b70e2f1ddab56dcf9aa947f92c7 /Parser
parent83c86cf54b36a7325f615f5adf22b28e48f0e72d (diff)
downloadcpython-0b290dd2171e745d94f48298cafb2327eb2de17c.zip
cpython-0b290dd2171e745d94f48298cafb2327eb2de17c.tar.gz
cpython-0b290dd2171e745d94f48298cafb2327eb2de17c.tar.bz2
bpo-42150: Avoid buffer overflow in the new parser (GH-22978)
(cherry picked from commit e68c67805e6a4c4ec80bea64be0e8373cc02d322) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/pegen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index 2c435fb..a7643fc 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -989,7 +989,8 @@ bad_single_statement(Parser *p)
/* Newlines are allowed if preceded by a line continuation character
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;
}
char c = *cur;