gh-111178: fix UBSan failures in Modules/curses*.c (GH-128244)

* fix UBSan failures in `_cursesmodule.c`
* fix UBSan failures in `_curses_panel.c`
* suppress an unused return value
This commit is contained in:
Bénédikt Tran 2025-01-03 15:12:40 +01:00 committed by GitHub
parent 8522f8bacb
commit 621d4ff35e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 114 additions and 71 deletions

View file

@ -62,7 +62,7 @@ _curses_panel_traverse(PyObject *mod, visitproc visit, void *arg)
static void
_curses_panel_free(void *mod)
{
_curses_panel_clear((PyObject *) mod);
(void)_curses_panel_clear((PyObject *)mod);
}
/* Utility Functions */
@ -101,6 +101,8 @@ typedef struct {
PyCursesWindowObject *wo; /* for reference counts */
} PyCursesPanelObject;
#define _PyCursesPanelObject_CAST(op) ((PyCursesPanelObject *)(op))
/* Some helper functions. The problem is that there's always a window
associated with a panel. To ensure that Python's GC doesn't pull
this window from under our feet we need to keep track of references
@ -277,9 +279,10 @@ PyCursesPanel_New(_curses_panel_state *state, PANEL *pan,
}
static void
PyCursesPanel_Dealloc(PyCursesPanelObject *po)
PyCursesPanel_Dealloc(PyObject *self)
{
PyObject *tp, *obj;
PyCursesPanelObject *po = _PyCursesPanelObject_CAST(self);
tp = (PyObject *) Py_TYPE(po);
obj = (PyObject *) panel_userptr(po->pan);