diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-07 18:55:49 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-07 18:55:49 (GMT) |
commit | 5e80855af3537f9715b33539d5b9860ca533a288 (patch) | |
tree | b6edf52a3ef9345a3ce4d44e38cf4d585f7ef9c2 /Parser/asdl_c.py | |
parent | 3df053e556c27dd8ed8fd20e1f1d652284132ff1 (diff) | |
parent | cf3806026b4f9784f97fce168695c3b4a6bbd8a5 (diff) | |
download | cpython-5e80855af3537f9715b33539d5b9860ca533a288.zip cpython-5e80855af3537f9715b33539d5b9860ca533a288.tar.gz cpython-5e80855af3537f9715b33539d5b9860ca533a288.tar.bz2 |
Issue #24098: Fixed possible crash when AST is changed in process of
compiling it.
Diffstat (limited to 'Parser/asdl_c.py')
-rw-r--r-- | Parser/asdl_c.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 17c8517..725d73b 100644 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -526,6 +526,13 @@ class Obj2ModVisitor(PickleVisitor): self.emit("res = obj2ast_%s(PyList_GET_ITEM(tmp, i), &value, arena);" % field.type, depth+2, reflow=False) self.emit("if (res != 0) goto failed;", depth+2) + self.emit("if (len != PyList_GET_SIZE(tmp)) {", depth+2) + self.emit("PyErr_SetString(PyExc_RuntimeError, \"%s field \\\"%s\\\" " + "changed size during iteration\");" % + (name, field.name), + depth+3, reflow=False) + self.emit("goto failed;", depth+3) + self.emit("}", depth+2) self.emit("asdl_seq_SET(%s, i, value);" % field.name, depth+2) self.emit("}", depth+1) else: |