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

Skip to content

gh-111178: fix UBSan failures in Modules/_bz2module.c #128238

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 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
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
14 changes: 10 additions & 4 deletions Modules/_bz2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ typedef struct {
PyThread_type_lock lock;
} BZ2Decompressor;

#define _BZ2Compressor_CAST(op) ((BZ2Compressor *)(op))
#define _BZ2Decompressor_CAST(op) ((BZ2Decompressor *)(op))

/* Helper functions. */

static int
Expand Down Expand Up @@ -376,8 +379,9 @@ _bz2_BZ2Compressor_impl(PyTypeObject *type, int compresslevel)
}

static void
BZ2Compressor_dealloc(BZ2Compressor *self)
BZ2Compressor_dealloc(PyObject *op)
{
BZ2Compressor *self = _BZ2Compressor_CAST(op);
BZ2_bzCompressEnd(&self->bzs);
if (self->lock != NULL) {
PyThread_free_lock(self->lock);
Expand All @@ -388,7 +392,7 @@ BZ2Compressor_dealloc(BZ2Compressor *self)
}

static int
BZ2Compressor_traverse(BZ2Compressor *self, visitproc visit, void *arg)
BZ2Compressor_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
return 0;
Expand Down Expand Up @@ -680,8 +684,10 @@ _bz2_BZ2Decompressor_impl(PyTypeObject *type)
}

static void
BZ2Decompressor_dealloc(BZ2Decompressor *self)
BZ2Decompressor_dealloc(PyObject *op)
{
BZ2Decompressor *self = _BZ2Decompressor_CAST(op);

if(self->input_buffer != NULL) {
PyMem_Free(self->input_buffer);
}
Expand All @@ -697,7 +703,7 @@ BZ2Decompressor_dealloc(BZ2Decompressor *self)
}

static int
BZ2Decompressor_traverse(BZ2Decompressor *self, visitproc visit, void *arg)
BZ2Decompressor_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
return 0;
Expand Down
Loading
0