Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-144986: Fix memory leak in atexit.register() (GH-144987)
(cherry picked from commit 50c1471)

Co-authored-by: Shamil <[email protected]>
  • Loading branch information
ashm-dev authored and miss-islington committed Feb 19, 2026
commit 2065be9d6ebe9f2dcbf8de07028ff2c3614d2a71
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a memory leak in :func:`atexit.register`.
Patch by Shamil Abdulaev.
4 changes: 4 additions & 0 deletions Modules/atexitmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,17 @@ atexit_register(PyObject *module, PyObject *args, PyObject *kwargs)
return NULL;
}
PyObject *func_args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
if (func_args == NULL) {
return NULL;
}
PyObject *func_kwargs = kwargs;

if (func_kwargs == NULL)
{
func_kwargs = Py_None;
}
PyObject *callback = PyTuple_Pack(3, func, func_args, func_kwargs);
Py_DECREF(func_args);
if (callback == NULL)
{
return NULL;
Expand Down
Loading