Skip to content

Commit 1a544e1

Browse files
[3.8] bpo-42425: Fix possible leak in initialization of errmap for OSError (GH-23446). (GH-24025)
(cherry picked from commit ed1007c)
1 parent e3a9adb commit 1a544e1

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
@@ -2518,8 +2518,10 @@ _PyExc_Init(void)
25182518
do { \
25192519
PyObject *_code = PyLong_FromLong(CODE); \
25202520
assert(_PyObject_RealIsSubclass(PyExc_ ## TYPE, PyExc_OSError)); \
2521-
if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) \
2521+
if (!_code || PyDict_SetItem(errnomap, _code, PyExc_ ## TYPE)) { \
2522+
Py_XDECREF(_code); \
25222523
return _PyStatus_ERR("errmap insertion problem."); \
2524+
} \
25232525
Py_DECREF(_code); \
25242526
} while (0)
25252527

0 commit comments

Comments
 (0)