Content-Length: 216115 | pFad | http://github.com/python/cpython/commit/68a8ca6dc10bdceb4efaac569081b78ec01c3a99

23 gh-101819: Harden _io init (#104352) · python/cpython@68a8ca6 · GitHub
Skip to content

Commit

Permalink
gh-101819: Harden _io init (#104352)
Browse files Browse the repository at this point in the history
Fix potential refleak if PyModule_AddObject() fails.
  • Loading branch information
erlend-aasland authored May 10, 2023
1 parent 22f3425 commit 68a8ca6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Modules/_io/_iomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -785,7 +787,6 @@ PyInit__io(void)
return m;

fail:
Py_XDECREF(state->unsupported_operation);
Py_DECREF(m);
return NULL;
}

0 comments on commit 68a8ca6

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/68a8ca6dc10bdceb4efaac569081b78ec01c3a99

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy