Skip to content

Commit e101a98

Browse files
committed
fix UBSan failures for PySSLMemoryBIO
1 parent e1c5020 commit e101a98

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Modules/_ssl.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ typedef struct {
347347
int eof_written;
348348
} PySSLMemoryBIO;
349349

350+
#define PySSLMemoryBIO_CAST(op) ((PySSLMemoryBIO *)(op))
351+
350352
typedef struct {
351353
PyObject_HEAD
352354
SSL_SESSION *session;
@@ -5314,19 +5316,20 @@ _ssl_MemoryBIO_impl(PyTypeObject *type)
53145316
}
53155317

53165318
static int
5317-
memory_bio_traverse(PySSLMemoryBIO *self, visitproc visit, void *arg)
5319+
memory_bio_traverse(PyObject *op, visitproc visit, void *arg)
53185320
{
5319-
Py_VISIT(Py_TYPE(self));
5321+
Py_VISIT(Py_TYPE(op));
53205322
return 0;
53215323
}
53225324

53235325
static void
5324-
memory_bio_dealloc(PySSLMemoryBIO *self)
5326+
memory_bio_dealloc(PyObject *op)
53255327
{
5328+
PySSLMemoryBIO *self = PySSLMemoryBIO_CAST(op);
53265329
PyTypeObject *tp = Py_TYPE(self);
53275330
PyObject_GC_UnTrack(self);
5328-
BIO_free(self->bio);
5329-
Py_TYPE(self)->tp_free(self);
5331+
(void)BIO_free(self->bio);
5332+
tp->tp_free(self);
53305333
Py_DECREF(tp);
53315334
}
53325335

0 commit comments

Comments
 (0)