From ba9be477b0098eefeae2dd36e9261434d83bfb57 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 31 Oct 2013 15:00:24 +0100 Subject: [PATCH] Issue #19437: Fix fill_and_set_sslerror() of _ssl, handle Py_BuildValue() failure Don't call PyObject_CallObject() with NULL parameters and an exception set. --- Modules/_ssl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 34a141bd27..ffcc4a9f61 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -346,14 +346,18 @@ fill_and_set_sslerror(PyObject *type, int ssl_errno, const char *errstr, lib_obj, errstr, lineno); else msg = PyUnicode_FromFormat("%s (_ssl.c:%d)", errstr, lineno); - if (msg == NULL) goto fail; + init_value = Py_BuildValue("iN", ssl_errno, msg); + if (init_value == NULL) + goto fail; + err_value = PyObject_CallObject(type, init_value); Py_DECREF(init_value); if (err_value == NULL) goto fail; + if (reason_obj == NULL) reason_obj = Py_None; if (_PyObject_SetAttrId(err_value, &PyId_reason, reason_obj)) -- 2.40.0