8000 fix UBSan failures for `PicklerMemoProxyObject` · python/cpython@0b1d726 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b1d726

Browse files
committed
fix UBSan failures for PicklerMemoProxyObject
1 parent d1e782c commit 0b1d726

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Modules/_pickle.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ typedef struct {
701701

702702
#define _PicklerObject_CAST(op) ((PicklerObject *)(op))
703703
#define _UnpicklerObject_CAST(op) ((UnpicklerObject *)(op))
704+
#define _PicklerMemoProxyObject_CAST(op) ((PicklerMemoProxyObject *)(op))
704705

705706
/* Forward declarations */
706707
static int save(PickleState *state, PicklerObject *, PyObject *, int);
@@ -4980,27 +4981,29 @@ static PyMethodDef picklerproxy_methods[] = {
49804981
};
49814982

49824983
static void
4983-
PicklerMemoProxy_dealloc(PicklerMemoProxyObject *self)
4984+
PicklerMemoProxy_dealloc(PyObject *op)
49844985
{
4986+
PicklerMemoProxyObject *self = _PicklerMemoProxyObject_CAST(op);
49854987
PyTypeObject *tp = Py_TYPE(self);
49864988
PyObject_GC_UnTrack(self);
49874989
Py_CLEAR(self->pickler);
4988-
tp->tp_free((PyObject *)self);
4990+
tp->tp_free(self);
49894991
Py_DECREF(tp);
49904992
}
49914993

49924994
static int
4993-
PicklerMemoProxy_traverse(PicklerMemoProxyObject *self,
4994-
visitproc visit, void *arg)
4995+
PicklerMemoProxy_traverse(PyObject *op, visitproc visit, void *arg)
49954996
{
4997+
PicklerMemoProxyObject *self = _PicklerMemoProxyObject_CAST(op);
49964998
Py_VISIT(Py_TYPE(self));
49974999
Py_VISIT(self->pickler);
49985000
return 0;
49995001
}
50005002

50015003
static int
5002-
PicklerMemoProxy_clear(PicklerMemoProxyObject *self)
5004+
PicklerMemoProxy_clear(PyObject *op)
50035005
{
5006+
PicklerMemoProxyObject *self = _PicklerMemoProxyObject_CAST(op);
50045007
Py_CLEAR(self->pickler);
50055008
return 0;
50065009
}

0 commit comments

Comments
 (0)
0