Skip to content
Merged
Prev Previous commit
Next Next commit
fix UBSan failures for localdummyobject
  • Loading branch information
picnixz committed Jan 25, 2025
commit 557dbd002bd5a2fe1d27a5728291ae0e5cef0b9c
11 changes: 7 additions & 4 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,17 @@ typedef struct {
PyObject *weakreflist; /* List of weak references to self */
} localdummyobject;

#define _localdummyobject_CAST(op) ((localdummyobject *)(op))

static void
localdummy_dealloc(PyObject *op)
{
localdummyobject *self = (localdummyobject*)op;
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
localdummyobject *self = _localdummyobject_CAST(op);
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs(op);
}
PyTypeObject *tp = Py_TYPE(self);
tp->tp_free((PyObject*)self);
tp->tp_free(self);
Py_DECREF(tp);
}

Expand Down