Skip to content

Commit a7bc29a

Browse files
committed
Fix build failing from undefined behavior of implicit casting structs.
1 parent a167c30 commit a7bc29a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src_c/include/pygame_mixer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef struct {
5050
PYGAMEAPI_DEFINE_SLOTS(mixer);
5151

5252
#define pgSound_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 0))
53-
#define pgSound_Check(x) (PyObject_IsInstance(x, &pgSound_Type))
53+
#define pgSound_Check(x) (PyObject_IsInstance(x, (PyObject *)&pgSound_Type))
5454

5555
#define pgSound_New \
5656
(*(PyObject * (*)(Mix_Chunk *)) PYGAMEAPI_GET_SLOT(mixer, 1))
@@ -59,7 +59,8 @@ PYGAMEAPI_DEFINE_SLOTS(mixer);
5959
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(mixer, 2))
6060

6161
#define pgChannel_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 3))
62-
#define pgChannel_Check(x) (PyObject_IsInstance(x, &pgChannel_Type))
62+
#define pgChannel_Check(x) \
63+
(PyObject_IsInstance(x, (PyObject *)&pgChannel_Type))
6364

6465
#define pgChannel_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(mixer, 4))
6566

src_c/mixer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ static PyObject *
8585
pgSound_New(Mix_Chunk *);
8686
static PyObject *
8787
pgChannel_New(int);
88-
#define pgSound_Check(x) (PyObject_IsInstance(x, &pgSound_Type))
89-
#define pgChannel_Check(x) (PyObject_IsInstance(x, &pgChannel_Type))
88+
#define pgSound_Check(x) (PyObject_IsInstance(x, (PyObject *)&pgSound_Type))
89+
#define pgChannel_Check(x) \
90+
(PyObject_IsInstance(x, (PyObject *)&pgChannel_Type))
9091

9192
static int
9293
snd_getbuffer(PyObject *, Py_buffer *, int);

0 commit comments

Comments
 (0)