8000 fix UBSan failures for `Pdata` · python/cpython@47cddff · GitHub
[go: up one dir, main page]

Skip to content

Commit 47cddff

Browse files
committed
fix UBSan failures for Pdata
1 parent cf0b2da commit 47cddff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Modules/_pickle.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,24 +410,27 @@ typedef struct {
410410
Py_ssize_t allocated; /* number of slots in data allocated */
411411
} Pdata;
412412

413+
#define _Pdata_CAST(op) ((Pdata *)(op))
414+
413415
static int
414-
Pdata_traverse(Pdata *self, visitproc visit, void *arg)
416+
Pdata_traverse(PyObject *self, visitproc visit, void *arg)
415417
{
416418
Py_VISIT(Py_TYPE(self));
417419
return 0;
418420
}
419421

420422
static void
421-
Pdata_dealloc(Pdata *self)
423+
Pdata_dealloc(PyObject *op)
422424
{
425+
Pdata *self = _Pdata_CAST(op);
423426
PyTypeObject *tp = Py_TYPE(self);
424427
PyObject_GC_UnTrack(self);
425428
Py_ssize_t i = Py_SIZE(self);
426429
while (--i >= 0) {
427430
Py_DECREF(self->data[i]);
428431
}
429432
PyMem_Free(self->data);
430-
tp->tp_free((PyObject *)self);
433+
tp->tp_free(self);
431434
Py_DECREF(tp);
432435
}
433436

0 commit comments

Comments
 (0)
0