Skip to content

Commit 702c4a2

Browse files
authored
gh-111178: fix some USAN failures - mismatched function pointers (GH-123004)
1 parent 0e21cc6 commit 702c4a2

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Objects/exceptions.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3387,8 +3387,9 @@ _PyErr_NoMemory(PyThreadState *tstate)
33873387
}
33883388

33893389
static void
3390-
MemoryError_dealloc(PyBaseExceptionObject *self)
3390+
MemoryError_dealloc(PyObject *obj)
33913391
{
3392+
PyBaseExceptionObject *self = (PyBaseExceptionObject *)obj;
33923393
_PyObject_GC_UNTRACK(self);
33933394

33943395
BaseException_clear(self);
@@ -3447,7 +3448,7 @@ PyTypeObject _PyExc_MemoryError = {
34473448
PyVarObject_HEAD_INIT(NULL, 0)
34483449
"MemoryError",
34493450
sizeof(PyBaseExceptionObject),
3450-
0, (destructor)MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0,
3451+
0, MemoryError_dealloc, 0, 0, 0, 0, 0, 0, 0,
34513452
0, 0, 0, 0, 0, 0, 0,
34523453
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
34533454
PyDoc_STR("Out of memory."), (traverseproc)BaseException_traverse,

Objects/rangeobject.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
143143

144144

145145
static PyObject *
146-
range_vectorcall(PyTypeObject *type, PyObject *const *args,
146+
range_vectorcall(PyObject *rangetype, PyObject *const *args,
147147
size_t nargsf, PyObject *kwnames)
148148
{
149149
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
150150
if (!_PyArg_NoKwnames("range", kwnames)) {
151151
return NULL;
152152
}
153-
return range_from_array(type, args, nargs);
153+
return range_from_array((PyTypeObject *)rangetype, args, nargs);
154154
}
155155

156156
PyDoc_STRVAR(range_doc,
@@ -803,7 +803,7 @@ PyTypeObject PyRange_Type = {
803803
0, /* tp_init */
804804
0, /* tp_alloc */
805805
range_new, /* tp_new */
806-
.tp_vectorcall = (vectorcallfunc)range_vectorcall
806+
.tp_vectorcall = range_vectorcall
807807
};
808808

809809
/*********************** range Iterator **************************/

Objects/tupleobject.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,9 @@ tupleiter_traverse(_PyTupleIterObject *it, visitproc visit, void *arg)
999999
}
10001000

10011001
static PyObject *
1002-
tupleiter_next(_PyTupleIterObject *it)
1002+
tupleiter_next(PyObject *obj)
10031003
{
1004+
_PyTupleIterObject *it = (_PyTupleIterObject *)obj;
10041005
PyTupleObject *seq;
10051006
PyObject *item;
10061007

@@ -1101,7 +1102,7 @@ PyTypeObject PyTupleIter_Type = {
11011102
0, /* tp_richcompare */
11021103
0, /* tp_weaklistoffset */
11031104
PyObject_SelfIter, /* tp_iter */
1104-
(iternextfunc)tupleiter_next, /* tp_iternext */
1105+
tupleiter_next, /* tp_iternext */
11051106
tupleiter_methods, /* tp_methods */
11061107
0,
11071108
};

0 commit comments

Comments
 (0)