Skip to content

Commit e1c5020

Browse files
committed
fix UBSan failures for PySSLSocket
1 parent 801a41c commit e1c5020

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Modules/_ssl.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ typedef struct {
339339
PyObject *exc;
340340
} PySSLSocket;
341341

342+
#define PySSLSocket_CAST(op) ((PySSLSocket *)(op))
343+
342344
typedef struct {
343345
PyObject_HEAD
344346
BIO *bio;
@@ -2319,23 +2321,26 @@ _ssl__SSLSocket_owner_set_impl(PySSLSocket *self, PyObject *value)
23192321
}
23202322

23212323
static int
2322-
PySSL_traverse(PySSLSocket *self, visitproc visit, void *arg)
2324+
PySSL_traverse(PyObject *op, visitproc visit, void *arg)
23232325
{
2326+
PySSLSocket *self = PySSLSocket_CAST(op);
23242327
Py_VISIT(self->exc);
23252328
Py_VISIT(Py_TYPE(self));
23262329
return 0;
23272330
}
23282331

23292332
static int
2330-
PySSL_clear(PySSLSocket *self)
2333+
PySSL_clear(PyObject *op)
23312334
{
2335+
PySSLSocket *self = PySSLSocket_CAST(op);
23322336
Py_CLEAR(self->exc);
23332337
return 0;
23342338
}
23352339

23362340
static void
2337-
PySSL_dealloc(PySSLSocket *self)
2341+
PySSL_dealloc(PyObject *op)
23382342
{
2343+
PySSLSocket *self = PySSLSocket_CAST(op);
23392344
PyTypeObject *tp = Py_TYPE(self);
23402345
PyObject_GC_UnTrack(self);
23412346
if (self->ssl) {

0 commit comments

Comments
 (0)