]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053)
authorPablo Galindo <Pablogsal@gmail.com>
Wed, 2 Sep 2020 16:44:19 +0000 (17:44 +0100)
committerGitHub <noreply@github.com>
Wed, 2 Sep 2020 16:44:19 +0000 (17:44 +0100)
commit4a97b1517a6b5ff22e2984b677a680b07ff0ce11
treed31c9d8aa26544863790e5643c79c10e0172f0c3
parent3940333637b98a2781869977b077552514784529
bpo-41690: Use a loop to collect args in the parser instead of recursion (GH-22053)

This program can segfault the parser by stack overflow:

```
import ast

code = "f(" + ",".join(['a' for _ in range(100000)]) + ")"
print("Ready!")
ast.parse(code)
```

the reason is that the rule for arguments has a simple recursion when collecting args:

args[expr_ty]:
    [...]
    | a=named_expression b=[',' c=args { c }] {
        [...] }
Grammar/python.gram
Misc/NEWS.d/next/Core and Builtins/2020-09-02-12-00-57.bpo-41690.Ny-Sfy.rst [new file with mode: 0644]
Parser/parser.c
Parser/pegen.c
Parser/pegen.h