Skip to content

Commit cf38060

Browse files
Issue python#24098: Fixed possible crash when AST is changed in process of
compiling it.
1 parent 36e7e97 commit cf38060

3 files changed

Lines changed: 226 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: TBA
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #24098: Fixed possible crash when AST is changed in process of
14+
compiling it.
15+
1316
- Issue #28350: String constants with null character no longer interned.
1417

1518
- Issue #26617: Fix crash when GC runs during weakref callbacks.

Parser/asdl_c.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,13 @@ def visitField(self, field, name, sum=None, prod=None, depth=0):
526526
self.emit("res = obj2ast_%s(PyList_GET_ITEM(tmp, i), &value, arena);" %
527527
field.type, depth+2, reflow=False)
528528
self.emit("if (res != 0) goto failed;", depth+2)
529+
self.emit("if (len != PyList_GET_SIZE(tmp)) {", depth+2)
530+
self.emit("PyErr_SetString(PyExc_RuntimeError, \"%s field \\\"%s\\\" "
531+
"changed size during iteration\");" %
532+
(name, field.name),
533+
depth+3, reflow=False)
534+
self.emit("goto failed;", depth+3)
535+
self.emit("}", depth+2)
529536
self.emit("asdl_seq_SET(%s, i, value);" % field.name, depth+2)
530537
self.emit("}", depth+1)
531538
else:

0 commit comments

Comments
 (0)