summaryrefslogtreecommitdiffstats
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 1a41024..c1a8eaa 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -6052,17 +6052,26 @@ sslmodule_init_errorcodes(PyObject *module)
errcode = error_codes;
while (errcode->mnemonic != NULL) {
- PyObject *mnemo, *key;
- mnemo = PyUnicode_FromString(errcode->mnemonic);
- key = Py_BuildValue("ii", errcode->library, errcode->reason);
- if (mnemo == NULL || key == NULL)
+ PyObject *mnemo = PyUnicode_FromString(errcode->mnemonic);
+ if (mnemo == NULL) {
return -1;
- if (PyDict_SetItem(state->err_codes_to_names, key, mnemo))
+ }
+ PyObject *key = Py_BuildValue("ii", errcode->library, errcode->reason);
+ if (key == NULL) {
+ Py_DECREF(mnemo);
return -1;
- if (PyDict_SetItem(state->err_names_to_codes, mnemo, key))
+ }
+ if (PyDict_SetItem(state->err_codes_to_names, key, mnemo) < 0) {
+ Py_DECREF(key);
+ Py_DECREF(mnemo);
return -1;
+ }
+ int rc = PyDict_SetItem(state->err_names_to_codes, mnemo, key);
Py_DECREF(key);
Py_DECREF(mnemo);
+ if (rc < 0) {
+ return -1;
+ }
errcode++;
}