Skip to content

Commit c056b13

Browse files
authored
Merge branch 'main' into fix-issue-128942-lockfree
2 parents 48eabe3 + 0a91456 commit c056b13

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix missing NULL check in ``_PyMem_FreeDelayed`` in :term:`free-threaded <free threading>` build.

Objects/obmalloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,9 @@ void
12151215
_PyMem_FreeDelayed(void *ptr)
12161216
{
12171217
assert(!((uintptr_t)ptr & 0x01));
1218-
free_delayed((uintptr_t)ptr);
1218+
if (ptr != NULL) {
1219+
free_delayed((uintptr_t)ptr);
1220+
}
12191221
}
12201222

12211223
#ifdef Py_GIL_DISABLED

Objects/typeobject.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,16 @@ _PyType_GetMRO(PyTypeObject *self)
574574
static inline void
575575
set_tp_mro(PyTypeObject *self, PyObject *mro, int initial)
576576
{
577-
assert(PyTuple_CheckExact(mro));
578-
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
579-
// XXX tp_mro can probably be statically allocated for each
580-
// static builtin type.
581-
assert(initial);
582-
assert(self->tp_mro == NULL);
583-
/* Other checks are done via set_tp_bases. */
584-
_Py_SetImmortal(mro);
577+
if (mro != NULL) {
578+
assert(PyTuple_CheckExact(mro));
579+
if (self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN) {
580+
// XXX tp_mro can probably be statically allocated for each
581+
// static builtin type.
582+
assert(initial);
583+
assert(self->tp_mro == NULL);
584+
/* Other checks are done via set_tp_bases. */
585+
_Py_SetImmortal(mro);
586+
}
585587
}
586588
self->tp_mro = mro;
587589
}

0 commit comments

Comments
 (0)