diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:35:15 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-25 16:35:15 (GMT) |
commit | 6a50e79130f6e78b8f967ec9f144032df9e41d61 (patch) | |
tree | d19bc7be3f3e860a1faa053d5bd7d5e293d6f173 /Objects/typeobject.c | |
parent | b64c94338b11aad4c6de5c2b515851d1a01985b1 (diff) | |
parent | 670d78abc5b9a9780677c9f1d51dcd543b15e0f7 (diff) | |
download | cpython-6a50e79130f6e78b8f967ec9f144032df9e41d61.zip cpython-6a50e79130f6e78b8f967ec9f144032df9e41d61.tar.gz cpython-6a50e79130f6e78b8f967ec9f144032df9e41d61.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/typeobject.c')
-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 10a0f60..9349330 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3897,8 +3897,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; } @@ -3907,6 +3909,7 @@ _PyObject_GetState(PyObject *obj) } else { int err = PyDict_SetItem(slots, name, value); + Py_DECREF(name); Py_DECREF(value); if (err) { goto error; |