mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #24097: Fixed crash in object.__reduce__() if slot name is freed inside
__getattr__. Original patch by Antoine Pitrou.
This commit is contained in:
parent
33e7ea5ad6
commit
d28bb624d1
3 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue