Skip to content

Commit c1478d1

Browse files
authored
gh-111178: fix UBSan failures in Modules/unicodedata.c (GH-129801)
fix UBSan failures for `PreviousDBVersion`
1 parent ecde940 commit c1478d1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Modules/unicodedata.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ typedef struct previous_version {
7777
Py_UCS4 (*normalization)(Py_UCS4);
7878
} PreviousDBVersion;
7979

80+
#define PreviousDBVersion_CAST(op) ((PreviousDBVersion *)(op))
81+
8082
#include "clinic/unicodedata.c.h"
8183

82-
#define get_old_record(self, v) ((((PreviousDBVersion*)self)->getrecord)(v))
84+
#define get_old_record(self, v) (PreviousDBVersion_CAST(self)->getrecord(v))
8385

8486
static PyMemberDef DB_members[] = {
8587
{"unidata_version", Py_T_STRING, offsetof(PreviousDBVersion, name), Py_READONLY},
@@ -1591,14 +1593,14 @@ static PyMethodDef unicodedata_functions[] = {
15911593
};
15921594

15931595
static int
1594-
ucd_traverse(PreviousDBVersion *self, visitproc visit, void *arg)
1596+
ucd_traverse(PyObject *self, visitproc visit, void *arg)
15951597
{
15961598
Py_VISIT(Py_TYPE(self));
15971599
return 0;
15981600
}
15991601

16001602
static void
1601-
ucd_dealloc(PreviousDBVersion *self)
1603+
ucd_dealloc(PyObject *self)
16021604
{
16031605
PyTypeObject *tp = Py_TYPE(self);
16041606
PyObject_GC_UnTrack(self);

0 commit comments

Comments
 (0)