Skip to content

Commit c6b9b31

Browse files
committed
bpo-42150: Avoid buffer overflow in the new parser
1 parent d1a0a96 commit c6b9b31

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix possible buffer overflow in the new parser when checking for
2+
continuation lines. Patch by Pablo Galindo.

Parser/pegen.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,8 @@ bad_single_statement(Parser *p)
990990

991991
/* Newlines are allowed if preceded by a line continuation character
992992
or if they appear inside a string. */
993-
if (!cur || *(cur - 1) == '\\' || newline_in_string(p, cur)) {
993+
if (!cur || (cur != p->tok->buf && *(cur - 1) == '\\')
994+
|| newline_in_string(p, cur)) {
994995
return 0;
995996
}
996997
char c = *cur;

0 commit comments

Comments
 (0)