diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-01-02 10:24:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-02 10:24:27 (GMT) |
commit | 7695d832565914efcedcc885feb129f5102aec90 (patch) | |
tree | 20ce95c7544d167ae88c893b2f683eb86dc6e094 /Objects | |
parent | 69120613c071e9327a9dc6e4b1ff21b2e94d885e (diff) | |
download | cpython-7695d832565914efcedcc885feb129f5102aec90.zip cpython-7695d832565914efcedcc885feb129f5102aec90.tar.gz cpython-7695d832565914efcedcc885feb129f5102aec90.tar.bz2 |
[3.9] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446). (GH-24057)
(cherry picked from commit ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9)
Diffstat (limited to 'Objects')
-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 e44ce72..eb72de5 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2531,8 +2531,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) |