8000 gh-111178: fix UBSan failures in `Modules/_struct.c` by picnixz · Pull Request #129793 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111178: fix UBSan failures in Modules/_struct.c #129793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 23, 2025
Prev Previous commit
Next Next commit
Do not add an underscore to the macro if none is needed.
  • Loading branch information
picnixz committed Feb 8, 2025
commit 3483d82047f17cd31645ec36e0f1b3deb543bfbf
10 changes: 5 additions & 5 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -2030,12 +2030,12 @@ typedef struct {
Py_ssize_t index;
} unpackiterobject;

#define _unpackiterobject_CAST(op) ((unpackiterobject *)(op))
#define unpackiterobject_CAST(op) ((unpackiterobject *)(op))

static void
unpackiter_dealloc(PyObject *op)
{
unpackiterobject *self = _unpackiterobject_CAST(op);
unpackiterobject *self = unpackiterobject_CAST(op);
/* bpo-31095: UnTrack is needed before calling any callbacks */
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
Expand All @@ -2048,7 +2048,7 @@ unpackiter_dealloc(PyObject *op)
static int
unpackiter_traverse(PyObject *op, visitproc visit, void *arg)
{
unpackiterobject *self = _unpackiterobject_CAST(op);
unpackiterobject *self = unpackiterobject_CAST(op);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->so);
Py_VISIT(self->buf.obj);
Expand All @@ -2059,7 +2059,7 @@ static PyObject *
unpackiter_len(PyObject *op, PyObject *Py_UNUSED(args))
{
Py_ssize_t len;
unpackiterobject *self = _unpackiterobject_CAST(op);
unpackiterobject *self = unpackiterobject_CAST(op);
if (self->so == NULL) {
len = 0;
}
Expand All @@ -2077,7 +2077,7 @@ static PyMethodDef unpackiter_methods[] = {
static PyObject *
unpackiter_iternext(PyObject *op)
{
unpackiterobject *self = _unpackiterobject_CAST(op);
unpackiterobject *self = unpackiterobject_CAST(op);
_structmodulestate *state = get_struct_state_iterinst(self);
PyObject *result;
if (self->so == NULL) {
Expand Down
Loading
0