Skip to content

Commit 7695d83

Browse files
[3.9] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446). (GH-24057)
(cherry picked from commit ed1007c)
1 parent 6912061 commit 7695d83

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Objects/exceptions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,8 +2531,10 @@ _PyExc_Init(void)
25312531
do { \
25322532
PyObject *_code = PyLong_FromLong(CODE); \
25332533
assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \
2534-
if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) \
2534+
if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) { \
2535+
Py_XDECREF(_code); \
25352536
return _PyStatus_ERR("errmap insertion problem."); \
2537+
} \
25362538
Py_DECREF(_code); \
25372539
} while (0)
25382540

0 commit comments

Comments
 (0)