diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:33:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:33:29 (GMT) |
commit | d28bb624d120466ba5ebdf5063286b2f309283ab (patch) | |
tree | fa51e9e30f4f0cc80d72a3f0d9184e42afdbfde9 /Objects | |
parent | 33e7ea5ad6a3027ef684ac7941fccf7c97d5cbd6 (diff) | |
download | cpython-d28bb624d120466ba5ebdf5063286b2f309283ab.zip cpython-d28bb624d120466ba5ebdf5063286b2f309283ab.tar.gz cpython-d28bb624d120466ba5ebdf5063286b2f309283ab.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 b38e0fb..ca5355a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3768,8 +3768,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; } @@ -3778,6 +3780,7 @@ _PyObject_GetState(PyObject *obj) } else { int err = PyDict_SetItem(slots, name, value); + Py_DECREF(name); Py_DECREF(value); if (err) { goto error; |