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

Skip to content

gh-111178: fix UBSan failures in Modules/_randommodule.c #129791

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 5 commits into from
Feb 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix UBSan failures for RandomObject
  • Loading branch information
picnixz committed Jan 25, 2025
commit 3beb26b461aa7bfc969e288fde4ca005b3911c6f
5 changes: 3 additions & 2 deletions Modules/_randommodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ typedef struct {
uint32_t state[N];
} RandomObject;

#define _RandomObject_CAST(op) ((RandomObject *)(op))

#include "clinic/_randommodule.c.h"

Expand Down Expand Up @@ -551,7 +552,7 @@ _random_Random_getrandbits_impl(RandomObject *self, int k)
}

static int
random_init(RandomObject *self, PyObject *args, PyObject *kwds)
random_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *arg = NULL;
_randomstate *state = _randomstate_type(Py_TYPE(self));
Expand All @@ -570,7 +571,7 @@ random_init(RandomObject *self, PyObject *args, PyObject *kwds)
if (PyTuple_GET_SIZE(args) == 1)
arg = PyTuple_GET_ITEM(args, 0);

return random_seed(self, arg);
return random_seed(_RandomObject_CAST(self), arg);
}


Expand Down
0