bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
This commit is contained in:
Pablo Galindo Salgado 2021-12-20 15:43:26 +00:00 committed by GitHub
parent 6ca78affc8
commit e9898bf153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 4602 additions and 3197 deletions

File diff suppressed because it is too large Load diff

View file

@ -815,6 +815,7 @@ void *
_PyPegen_run_parser(Parser *p)
{
void *res = _PyPegen_parse(p);
assert(p->level == 0);
if (res == NULL) {
if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_SyntaxError)) {
return NULL;