diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:35:33 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:35:33 (GMT) |
commit | ee1b24ccaaab4efd583f30a27957ed9fdf374e2e (patch) | |
tree | 8bca87b8ae5e503eef40631f22e7b37256e3af79 /Objects | |
parent | 282e831a5a851df2b66da2e4902ad64cbe035930 (diff) | |
download | cpython-ee1b24ccaaab4efd583f30a27957ed9fdf374e2e.zip cpython-ee1b24ccaaab4efd583f30a27957ed9fdf374e2e.tar.gz cpython-ee1b24ccaaab4efd583f30a27957ed9fdf374e2e.tar.bz2 |
Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__. Original patch by Antoine Pitrou.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 720a84e..38548fd 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3269,12 +3269,16 @@ reduce_2(PyObject *obj) for (i = 0; i < PyList_GET_SIZE(names); i++) { PyObject *name, *value; name = PyList_GET_ITEM(names, i); + Py_INCREF(name); value = PyObject_GetAttr(obj, name); - if (value == NULL) + if (value == NULL) { + Py_DECREF(name); PyErr_Clear(); + } else { int err = PyDict_SetItem(slots, name, value); + Py_DECREF(name); Py_DECREF(value); if (err) goto end; |