diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:34:19 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:34:19 (GMT) |
commit | 670d78abc5b9a9780677c9f1d51dcd543b15e0f7 (patch) | |
tree | 2eb1e4c7490c55058e9c88d803f6d1ebd546c9ab /Objects | |
parent | 2cefc1efa2fc74da0ec1b79f75639b76ac8e6dfd (diff) | |
parent | d28bb624d120466ba5ebdf5063286b2f309283ab (diff) | |
download | cpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.zip cpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.tar.gz cpython-670d78abc5b9a9780677c9f1d51dcd543b15e0f7.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 | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f87d58f..0b94fc5 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3889,8 +3889,10 @@ _PyObject_GetState(PyObject *obj) PyObject *name, *value; name = PyList_GET_ITEM(slotnames, i); + Py_INCREF(name); value = PyObject_GetAttr(obj, name); if (value == NULL) { + Py_DECREF(name); if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { goto error; } @@ -3899,6 +3901,7 @@ _PyObject_GetState(PyObject *obj) } else { int err = PyDict_SetItem(slots, name, value); + Py_DECREF(name); Py_DECREF(value); if (err) { goto error; |