mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-111178: fix UBSan failures in Modules/_bz2module.c
(GH-128238)
This commit is contained in:
parent
6cf31750e0
commit
49d78158c0
1 changed files with 10 additions and 4 deletions
|
@ -129,6 +129,9 @@ typedef struct {
|
||||||
PyThread_type_lock lock;
|
PyThread_type_lock lock;
|
||||||
} BZ2Decompressor;
|
} BZ2Decompressor;
|
||||||
|
|
||||||
|
#define _BZ2Compressor_CAST(op) ((BZ2Compressor *)(op))
|
||||||
|
#define _BZ2Decompressor_CAST(op) ((BZ2Decompressor *)(op))
|
||||||
|
|
||||||
/* Helper functions. */
|
/* Helper functions. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -376,8 +379,9 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
BZ2Compressor_dealloc(BZ2Compressor *self)
|
BZ2Compressor_dealloc(PyObject *op)
|
||||||
{
|
{
|
||||||
|
BZ2Compressor *self = _BZ2Compressor_CAST(op);
|
||||||
BZ2_bzCompressEnd(&self->bzs);
|
BZ2_bzCompressEnd(&self->bzs);
|
||||||
if (self->lock != NULL) {
|
if (self->lock != NULL) {
|
||||||
PyThread_free_lock(self->lock);
|
PyThread_free_lock(self->lock);
|
||||||
|
@ -388,7 +392,7 @@ BZ2Compressor_dealloc(BZ2Compressor *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
BZ2Compressor_traverse(BZ2Compressor *self, visitproc visit, void *arg)
|
BZ2Compressor_traverse(PyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Py_TYPE(self));
|
Py_VISIT(Py_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -680,8 +684,10 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
BZ2Decompressor_dealloc(BZ2Decompressor *self)
|
BZ2Decompressor_dealloc(PyObject *op)
|
||||||
{
|
{
|
||||||
|
BZ2Decompressor *self = _BZ2Decompressor_CAST(op);
|
||||||
|
|
||||||
if(self->input_buffer != NULL) {
|
if(self->input_buffer != NULL) {
|
||||||
PyMem_Free(self->input_buffer);
|
PyMem_Free(self->input_buffer);
|
||||||
}
|
}
|
||||||
|
@ -697,7 +703,7 @@ BZ2Decompressor_dealloc(BZ2Decompressor *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
BZ2Decompressor_traverse(BZ2Decompressor *self, visitproc visit, void *arg)
|
BZ2Decompressor_traverse(PyObject *self, visitproc visit, void *arg)
|
||||||
{
|
{
|
||||||
Py_VISIT(Py_TYPE(self));
|
Py_VISIT(Py_TYPE(self));
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue