mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-131711: Preventing the use of a null pointer in set_tp_mro (#131713)
This commit is contained in:
parent
f1967e7249
commit
44605aa93d
1 changed files with 10 additions and 8 deletions
|
|
@ -574,14 +574,16 @@ _PyType_GetMRO(PyTypeObject *self)
|
|||
static inline void
|
||||
set_tp_mro(PyTypeObject *self, PyObject *mro, int initial)
|
||||
{
|
||||
assert(PyTuple_CheckExact(mro));
|
||||
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
|
||||
// XXX tp_mro can probably be statically allocated for each
|
||||
// static builtin type.
|
||||
assert(initial);
|
||||
assert(self->tp_mro == NULL);
|
||||
/* Other checks are done via set_tp_bases. */
|
||||
_Py_SetImmortal(mro);
|
||||
if (mro != NULL) {
|
||||
assert(PyTuple_CheckExact(mro));
|
||||
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
|
||||
// XXX tp_mro can probably be statically allocated for each
|
||||
// static builtin type.
|
||||
assert(initial);
|
||||
assert(self->tp_mro == NULL);
|
||||
/* Other checks are done via set_tp_bases. */
|
||||
_Py_SetImmortal(mro);
|
||||
}
|
||||
}
|
||||
self->tp_mro = mro;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue