mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #16447: Fix potential segfault when setting __name__ on a class.
This commit is contained in:
parent
eff6444751
commit
64aafeb4de
3 changed files with 21 additions and 1 deletions
|
|
@ -298,10 +298,13 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
|
|||
|
||||
Py_INCREF(value);
|
||||
|
||||
Py_DECREF(et->ht_name);
|
||||
/* Wait until et is a sane state before Py_DECREF'ing the old et->ht_name
|
||||
value. (Bug #16447.) */
|
||||
tmp = et->ht_name;
|
||||
et->ht_name = value;
|
||||
|
||||
type->tp_name = tp_name;
|
||||
Py_DECREF(tmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue