Skip to content

Fix memory leak in py_uwsgi_spooler_pids#2703

Open
henyu6 wants to merge 2 commits into
unbit:masterfrom
henyu6:fix-leak-spooler-pids
Open

Fix memory leak in py_uwsgi_spooler_pids#2703
henyu6 wants to merge 2 commits into
unbit:masterfrom
henyu6:fix-leak-spooler-pids

Conversation

@henyu6

@henyu6 henyu6 commented Jan 30, 2025

Copy link
Copy Markdown

When we call PyInt_FromLong, the reference count is increased and PyList_Append increasing the reference count again because when using PyList_Append, the reference count is incremented and not taken.

The change made is to set the result of PyInt_FromLong, append it to the list, then decrement the reference count.

@henyu6 henyu6 force-pushed the fix-leak-spooler-pids branch from ea40863 to 30470ba Compare January 30, 2025 01:13
Comment thread plugins/python/uwsgi_pymodule.c Outdated
struct uwsgi_spooler *uspool = uwsgi.spoolers;
while (uspool) {
PyList_Append(ret, PyInt_FromLong(uspool->pid));
PyObject *spool_pid = PyInt_FromLong(uspool->pid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a semicolon ";" missing at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants