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

Skip to content

gh-111178: fix UBSan failures in Modules/_ssl.c #130719

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 10 commits into from
Mar 17, 2025
Prev Previous commit
Next Next commit
fix UBSan failures for PySSLSocket
  • Loading branch information
picnixz committed Feb 8, 2025
commit e1c502056357e1845c5ac90370caec30d9d805d1
11 changes: 8 additions & 3 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ typedef struct {
PyObject *exc;
} PySSLSocket;

#define PySSLSocket_CAST(op) ((PySSLSocket *)(op))

typedef struct {
PyObject_HEAD
BIO *bio;
Expand Down Expand Up @@ -2319,23 +2321,26 @@ _ssl__SSLSocket_owner_set_impl(PySSLSocket *self, PyObject *value)
}

static int
PySSL_traverse(PySSLSocket *self, visitproc visit, void *arg)
PySSL_traverse(PyObject *op, visitproc visit, void *arg)
{
PySSLSocket *self = PySSLSocket_CAST(op);
Py_VISIT(self->exc);
Py_VISIT(Py_TYPE(self));
return 0;
}

static int
PySSL_clear(PySSLSocket *self)
PySSL_clear(PyObject *op)
{
PySSLSocket *self = PySSLSocket_CAST(op);
Py_CLEAR(self->exc);
return 0;
}

static void
PySSL_dealloc(PySSLSocket *self)
PySSL_dealloc(PyObject *op)
{
PySSLSocket *self = PySSLSocket_CAST(op);
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
if (self->ssl) {
Expand Down
0