mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
Fix #10673
This commit is contained in:
parent
cd1dc74270
commit
7e2a3cf81f
2 changed files with 9 additions and 16 deletions
|
|
@ -482,6 +482,9 @@ Detailed list of changes
|
|||
:option:`kitten @ set-colors --reset` not restoring them and not resetting all
|
||||
windows and the configured colors when used from the command line
|
||||
|
||||
- macOS: Fix a memory leak when getting the list of all processes, for
|
||||
example, when querying the memory used by child processes (:iss:`10673`)
|
||||
|
||||
|
||||
0.49.2 [2026-10-01]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -71,29 +71,19 @@ get_all_processes(PyObject *self UNUSED, PyObject *args UNUSED) {
|
|||
pid_t num = proc_listallpids(NULL, 0);
|
||||
if (num <= 0) return PyTuple_New(0);
|
||||
size_t sz = sizeof(pid_t) * num * 2;
|
||||
pid_t *buf = malloc(sz);
|
||||
RAII_ALLOC(pid_t, buf, malloc(sz));
|
||||
if (!buf) return PyErr_NoMemory();
|
||||
num = proc_listallpids(buf, sz);
|
||||
if (num <= 0) {
|
||||
free(buf);
|
||||
return PyTuple_New(0);
|
||||
}
|
||||
PyObject *ans = PyTuple_New(num);
|
||||
if (!ans) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
if (num <= 0) return PyTuple_New(0);
|
||||
RAII_PyObject(ans, PyTuple_New(num));
|
||||
if (!ans) return NULL;
|
||||
for (pid_t i = 0; i < num; i++) {
|
||||
long long pid = buf[i];
|
||||
PyObject *t = PyLong_FromLongLong(pid);
|
||||
if (!t) {
|
||||
free(buf);
|
||||
Py_CLEAR(ans);
|
||||
return NULL;
|
||||
}
|
||||
if (!t) return NULL;
|
||||
PyTuple_SET_ITEM(ans, i, t);
|
||||
}
|
||||
return ans;
|
||||
return Py_NewRef(ans);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue