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

Skip to content

gh-111178: fix UBSan failures in Modules/_dbm 8000 module.c #129775

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 10, 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
Prev Previous commit
Do not add an underscore to the prefix if none is needed.
  • Loading branch information
picnixz committed Feb 8, 2025
commit 2bc23804f06010e5a284a19c3bb73ba0403dd779
16 changes: 8 additions & 8 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct {
DBM *di_dbm;
} dbmobject;

#define _dbmobject_CAST(op) ((dbmobject *)(op))
#define dbmobject_CAST(op) ((dbmobject *)(op))

#include "clinic/_dbmmodule.c.h"

Expand Down Expand Up @@ -105,7 +105,7 @@ dbm_traverse(PyObject *dp, visitproc visit, void *arg)
static void
dbm_dealloc(PyObject *self)
{
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
PyObject_GC_UnTrack(dp);
if (dp->di_dbm) {
dbm_close(dp->di_dbm);
Expand All @@ -118,7 +118,7 @@ dbm_dealloc(PyObject *self)
static Py_ssize_t
dbm_length(PyObject *self)
{
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
_dbm_state *state = PyType_GetModuleState(Py_TYPE(dp));
assert(state != NULL);
if (dp->di_dbm == NULL) {
Expand All @@ -141,7 +141,7 @@ dbm_length(PyObject *self)
static int
dbm_bool(PyObject *self)
{
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
_dbm_state *state = PyType_GetModuleState(Py_TYPE(dp));
assert(state != NULL);

Expand Down Expand Up @@ -175,7 +175,7 @@ dbm_subscript(PyObject *self, PyObject *key)
{
datum drec, krec;
Py_ssize_t tmp_size;
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
_dbm_state *state = PyType_GetModuleState(Py_TYPE(dp));
assert(state != NULL);
if (!PyArg_Parse(key, "s#", &krec.dptr, &tmp_size)) {
Expand All @@ -202,7 +202,7 @@ dbm_ass_sub(PyObject *self, PyObject *v, PyObject *w)
{
datum krec, drec;
Py_ssize_t tmp_size;
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);

if ( !PyArg_Parse(v, "s#", &krec.dptr, &tmp_size) ) {
PyErr_SetString(PyExc_TypeError,
Expand Down Expand Up @@ -312,7 +312,7 @@ _dbm_dbm_keys_impl(dbmobject *self, PyTypeObject *cls)
static int
dbm_contains(PyObject *self, PyObject *arg)
{
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
datum key, val;
Py_ssize_t size;

Expand Down Expand Up @@ -467,7 +467,7 @@ dbm__enter__(PyObject *self, PyObject *Py_UNUSED(dummy))
static PyObject *
dbm__exit__(PyObject *self, PyObject *Py_UNUSED(args))
{
dbmobject *dp = _dbmobject_CAST(self);
dbmobject *dp = dbmobject_CAST(self);
return _dbm_dbm_close_impl(dp);
}

Expand Down
Loading
0