summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-11-21 17:17:46 (GMT)
committerGitHub <noreply@github.com>2020-11-21 17:17:46 (GMT)
commited1007c0d74e658d1e6c9b51b12ce7501eb8cbf9 (patch)
treef08fd4467c282ea4b1cd1894ecac1039f7cc7d25 /Objects
parent0e62efc51e31c741b61604787aeab4936e6e50e4 (diff)
downloadcpython-ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9.zip
cpython-ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9.tar.gz
cpython-ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9.tar.bz2
bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index b14da20..d482493 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -2547,8 +2547,10 @@ _PyExc_Init(PyThreadState *tstate)
do { \
PyObject *_code = PyLong_FromLong(CODE); \
assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \
- if (!_code || PyDict_SetItem(state->errnomap, _code, PyExc_ ## TYPE)) \
+ if (!_code || PyDict_SetItem(state->errnomap, _code, PyExc_ ## TYPE)) { \
+ Py_XDECREF(_code); \
return _PyStatus_ERR("errmap insertion problem."); \
+ } \
Py_DECREF(_code); \
} while (0)