mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
gh-101819: Harden _io init (#104352)
Fix potential refleak if PyModule_AddObject() fails.
This commit is contained in:
parent
22f3425c3d
commit
68a8ca6dc1
1 changed files with 4 additions and 3 deletions
|
|
@ -730,9 +730,11 @@ PyInit__io(void)
|
|||
"UnsupportedOperation", PyExc_OSError, PyExc_ValueError);
|
||||
if (state->unsupported_operation == NULL)
|
||||
goto fail;
|
||||
if (PyModule_AddObject(m, "UnsupportedOperation",
|
||||
Py_NewRef(state->unsupported_operation)) < 0)
|
||||
if (PyModule_AddObjectRef(m, "UnsupportedOperation",
|
||||
state->unsupported_operation) < 0)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* BlockingIOError, for compatibility */
|
||||
if (PyModule_AddObjectRef(m, "BlockingIOError",
|
||||
|
|
@ -785,7 +787,6 @@ PyInit__io(void)
|
|||
return m;
|
||||
|
||||
fail:
|
||||
Py_XDECREF(state->unsupported_operation);
|
||||
Py_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue