diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-01-01 17:40:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-01 17:40:11 (GMT) |
commit | 1a544e1dcf8e0880ee35ce78a7f90fc4e5c98c4f (patch) | |
tree | 72194344e6e00555ba59a14da2b92a18e7b89324 | |
parent | e3a9adba329681b1b73b7223515e71e94fc35e12 (diff) | |
download | cpython-1a544e1dcf8e0880ee35ce78a7f90fc4e5c98c4f.zip cpython-1a544e1dcf8e0880ee35ce78a7f90fc4e5c98c4f.tar.gz cpython-1a544e1dcf8e0880ee35ce78a7f90fc4e5c98c4f.tar.bz2 |
[3.8] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446). (GH-24025)
(cherry picked from commit ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9)
-rw-r--r-- | Objects/exceptions.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 8bcf76f..d22ed6f 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2518,8 +2518,10 @@ _PyExc_Init(void) do { \ PyObject *_code = PyLong_FromLong(CODE); \ assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \ - if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) \ + if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) { \ + Py_XDECREF(_code); \ return _PyStatus_ERR("errmap insertion problem."); \ + } \ Py_DECREF(_code); \ } while (0) |