summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-12-20 15:43:26 (GMT)
committerGitHub <noreply@github.com>2021-12-20 15:43:26 (GMT)
commite9898bf153d26059261ffef11f7643ae991e2a4c (patch)
tree07923519cbb9265c39c1d7139ae725b4db7ac586 /Parser/pegen.c
parent6ca78affc8023bc5023189d64d8050857662042a (diff)
downloadcpython-e9898bf153d26059261ffef11f7643ae991e2a4c.zip
cpython-e9898bf153d26059261ffef11f7643ae991e2a4c.tar.gz
cpython-e9898bf153d26059261ffef11f7643ae991e2a4c.tar.bz2
bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r--Parser/pegen.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 870085e..cfea1c8 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -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;