From a02ebdedc945fedb7173edfed5ad4d6f7a04a760 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Tue, 5 Oct 2021 18:53:42 +0200 Subject: [PATCH] fix #1965 / win / users() / critical: Py_INCREF(Py_None) before setting None object in C Signed-off-by: Giampaolo Rodola --- HISTORY.rst | 2 ++ psutil/_psutil_windows.c | 1 + 2 files changed, 3 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index adcaaa459..55c6b2b95 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -33,6 +33,8 @@ XXXX-XX-XX by Xuehai Pan) - 1953_: [Windows] disk_partitions() crashes due to insufficient buffer len. (patch by MaWe2019) +- 1965_: [Windows] fix "Fatal Python error: deallocating None" when calling + psutil.users() multiple times. - 1991_: process_iter() can raise TypeError if invoked from multiple threads (not thread-safe). diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index 13cf58c48..8abd8a8d7 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -1252,6 +1252,7 @@ psutil_users(PyObject *self, PyObject *args) { goto error; } else { + Py_INCREF(Py_None); py_address = Py_None; }