[3.9] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446). (GH-24057)

(cherry picked from commit ed1007c0d7)
This commit is contained in:
Serhiy Storchaka 2021-01-02 12:24:27 +02:00 committed by GitHub
parent 69120613c0
commit 7695d83256
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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)