mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
SF #1377897, Bus error in ast
If a line had multiple semi-colons and ended with a semi-colon, we would loop too many times and access a NULL node. Exit the loop early if there are no more children.
This commit is contained in:
parent
8ad64aaacc
commit
f8d403dd97
2 changed files with 9 additions and 0 deletions
|
@ -2562,6 +2562,11 @@ ast_for_suite(struct compiling *c, const node *n)
|
|||
ch = CHILD(ch, 0);
|
||||
REQ(ch, simple_stmt);
|
||||
for (j = 0; j < NCH(ch); j += 2) {
|
||||
/* statement terminates with a semi-colon ';' */
|
||||
if (NCH(CHILD(ch, j)) == 0) {
|
||||
assert((j + 1) == NCH(ch));
|
||||
break;
|
||||
}
|
||||
s = ast_for_stmt(c, CHILD(ch, j));
|
||||
if (!s)
|
||||
goto error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue