]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.8] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446...
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 1 Jan 2021 17:40:11 +0000 (19:40 +0200)
committerGitHub <noreply@github.com>
Fri, 1 Jan 2021 17:40:11 +0000 (19:40 +0200)
(cherry picked from commit ed1007c0d74e658d1e6c9b51b12ce7501eb8cbf9)

Objects/exceptions.c

index 8bcf76ff860a222df7997530e7cb799fbe6dea4c..d22ed6f039ac200cc80eeb0f71aa8dbff2aceea2 100644 (file)
@@ -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)